neodatis.odb 第五篇 保存

本文介绍了一个使用ODB进行对象持久化的示例代码,包括定义球员(Player)及运动(Sport)类,并将实例蒂埃里·亨利及其喜爱的足球运动存储到数据库中。该过程涉及数据库打开、对象存储位置分配等步骤。

  ODB odb = null;
  Sport soccer = new Sport("足球");  
  
  SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
  Player 亨利 = new Player("蒂埃里·亨利", format.parse("1977-8-17"), soccer);
  try {
   odb = ODBFactory.open("test.odb");
   OID oid1 = odb.store(亨利);
……

123456789101112131415161718192021222324252627282930
1/42/43/44/4
database iddatabase iddatabase id 
313233343536373839404142434445464748495051525354555657585960
 21FALSEFALSEusername
database idnb classesfirst class info oidodb
last
close
status
databse
without
user,pw
no-user
616263646566676869707172737475767778798081828384858687888990
username
919293949596979899100101102103104105106107108109110111112113114115116117118119120
 password
121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
password155
151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
 18034201-1-11
current id bolck positionblock size  prev block posnext block posid block number
181182183184185186187188189190       198199200201202203204205206207208209210
52
(代表CLASS) 
11
ACTIVE
181892
(代表CLASS) 
1
id block max id updateid
type
oidid
status
class
position
of
id
id
type
oid
211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
 1183091
(代表OBJECT)
3118589
241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
 1
(代表OBJECT)
4118765   
 
Player类
18189   181931819418195       18203       18211       
120121-12
block sizeclass
header
block
type
Class
info
category
class
id
prev
class
oid
next
class
oid
18219        18227       18235       18243    
0 -1-1Playe
class nb objects class
first
obj
pos
class last obj pos值(2×字符数+8)
18248              18263           18275  
rmars.odb.pojo
 值(2×字符数+8)
18297   18301       18309 
318466 
Max attribute idclass att def pos 
 
Sport类
18309   183131831418315       18323       18331       
1181221-1
block sizeclass
header
block
type
Class
info
category
class
id
prev
class
oid
next
class
oid
18339        18347       18355       18363    
0 -1-1Sport
class nb objects class
first
obj
pos
class last obj pos值(2×字符数+8)
             18381             
 mars.odb.pojo
 值(2×字符数+8)
18415   18419       18427 
118427 
Max attribute idclass att def pos 
 
Sport属性
18427   1843118432       18440   18445   18449    
392`1210(java.lang.String)name
block sizeBLOCK_
TYPE_
CLASS_
BODY
class
nb
attributes
attribute
id
att
odb
type
id
 
 
Player属性
18466   1847018471       18479   18484   18488        
123231210(java.lang.String)name
block sizeBLOCK_
TYPE_
CLASS_
BODY
class
nb
attributes
attribute
id
att
odb
type
id
值(2×字符数+8)
        18505    18510   18514            
 2 170(java.util.Date)birthDate
 attribute
id
 att
odb
type
id
值(2×字符数+8)
              18541   18546       18554   
 32favoriteSport
 attribute
id
class
info
id
值(2×字符数+8)
 
Player对象
18589   18593 18594       18602       18610       
2884
BLOCK_
TYPE_
NON_
NATIVE_
OBJECT
 31-1
block
size
object
block
type
 oidclass
info
id
[对象id]
prev instance
18618       18626       18634       18642   18646 
-1[1211898399406][1211898399859]1 
next instancecreation dateupdate dateobject version number 
      1865418655   18659   18663       18671    
-1FALSE31186952
object reference pointeris
syncronized
with
external
db
nb
attr
[属性数量]
attr idatt posattr id
18675       18683   18687        18695   1869918700   
187473-493
BLOCK_
TYPE_
NATIVE_
OBJECT
210
att posattr idatt posnative
block
header
block
size
native
block
type
 native
block
odb
type
id
18705   ……18747   1875118752   18757        
蒂埃里·亨利93
BLOCK_
TYPE_
NATIVE_
OBJECT
170[222278880000]
值(2×字符数+8)native
block
header
block
size
native
block
type
native block odb type id
 
Sport对象
18765   18769 
1124
block sizeobject
block
type
18770       18778       18786       18794     
42-1-1
oidclass info idprev instancenext instance
  18802       18810       18818   18822       
 [1211898576968][1211898577203]1-1
 creation dateupdate dateobject
version
number
object
reference
pointer
1883018831   18835   18839       18847   1885118852   18857  18617
FALSE111884793
BLOCK_
TYPE_
NATIVE_
OBJECT
210足球
is
syncronized
external
db
nb attrattr idatt pos/att real posnative
block
header
block
size
native
block
type
 native block odb type id值(2×字符数+8)
代码转载自:https://pan.quark.cn/s/7f503284aed9 Hibernate的核心组件总数达到五个,具体包括:Session、SessionFactory、Transaction、Query以及Configuration。 这五个核心组件在各类开发项目中都具有普遍的应用性。 借助这些组件,不仅可以高效地进行持久化对象的读取与存储,还能够实现事务管理功能。 接下来将通过图形化的方式,逐一阐述这五个核心组件的具体细节。 依据所提供的文件内容,可以总结出以下几个关键知识点:### 1. SSH框架详细架构图尽管标题提及“SSH框架详细架构图”,但在描述部分并未直接呈现关于SSH的详细内容,而是转向介绍了Hibernate的核心接口。 然而,在此我们可以简要概述SSH框架(涵盖Spring、Struts、Hibernate)的核心理念及其在Java开发中的具体作用。 #### Spring框架- **定义**:Spring框架是一个开源架构,其设计目标在于简化企业级应用的开发流程。 - **特点**: - **分层结构**:该框架允许开发者根据实际需求选择性地采纳部分组件,而非强制使用全部功能。 - **可复用性**:Spring框架支持创建可在不同开发环境中重复利用的业务逻辑和数据访问组件。 - **核心构成**: - **核心容器**:该部分包含了Spring框架的基础功能,其核心在于`BeanFactory`,该组件通过工厂模式运作,并借助控制反转(IoC)理念,将配置和依赖管理与具体的应用代码进行有效分离。 - **Spring上下文**:提供一个配置文件,其中整合了诸如JNDI、EJB、邮件服务、国际化支持等企业级服务。 - **Spring AO...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值