国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
嘗試hibernate annotations
最近開始嘗試hibernate annotations,終于成功的將手上一個小應(yīng)用轉(zhuǎn)為annotations

1、spring orm support
與原來使用LocalSessionFactoryBean相比,變動不大(AnnotationSessionFactoryBean本來就是從LocalSessionFactoryBean類繼承過來的嘛)
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> 1    <bean
 2         id="sessionFactory"

 3         class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
 4         parent="AbstractSessionFactory">
 5         <property name="annotatedClasses">
 6             <list>
 7                 <value>xxx.xxx.xxx.domain.Accountvalue>
 8             list>
 9         property>
10     bean>
11     <bean
12         id="AbstractSessionFactory"

13         class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
14         abstract="true">
15         <property
16             name="dataSource"

17             ref="DataSource" />
18         <property name="hibernateProperties">
19             <props>
20                 <prop key="hibernate.dialect">${hibernate.dialect}prop>
21                 <prop key="hibernate.show_sql">${hibernate.show_sql}prop>
22                 <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}prop>
23                 <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}prop>
24                 <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}prop>
25             props>
26         property>
27         <property
28             name="lobHandler"

29             ref="DefaultLobHandler" />
30     bean>
2、id的配置
非常簡單,在id的getter上面加個“@Id”就可以了。此時采用的id策略是javax.persistence.GenerationType.AUTO,也可以再加上“@GeneratedValue(generator =GenerationType.IDENTITY|GenerationType.SEQUENCE|GenerationType.TABLE)”換成其它策略。
我的應(yīng)用采用的是hibernate的uuid策略,就不得不在這兒使用hibernate的擴展了
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->  @Id
  @Column(length 
= 32
)
  @GeneratedValue(generator 
= "system-uuid"
)
  @GenericGenerator(name 
= "system-uuid", strategy = "uuid")

3、級聯(lián)策略
在ejb3-persistence.jar中只定義了ALL、MERGE、PERSIST、REFRESH、REMOVE,比較惡心的就是,刪除對象的時候,并不會級聯(lián)刪除關(guān)聯(lián)對象,而是用update xx set parent_id=null where parent_id=?這類語句把關(guān)系干掉了事。不得已,在這兒用了hibernate的DELETE_ORPHAN。
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->  @OneToMany(targetEntity = Attachment.class)
  @Cascade(value 
=
 {org.hibernate.annotations.CascadeType.DELETE_ORPHAN,
      org.hibernate.annotations.CascadeType.ALL})
  @JoinColumn(name 
= "info_id")
4、CACHE
ejb3-persistence.jar里面沒有找到cache的配置,繼續(xù)請出hibernate來干活
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->import org.hibernate.annotations.Cache;
import
 org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name 
= "T_INFO"
)
@Cache(usage 
= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
5、自定義字段類型
我的POJO中有一個private String content;的屬性,按ejb3配成@Lob后,被處理成了text類型,text 64k的存儲容量還是比較可憐了。
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->  @Lob
  @Column(columnDefinition 
= "LongText")
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
hibernate
Hibernate ehcache二級緩存技術(shù)
配置Spring+hibernate使用ehcache作為second-level cache
apache tomcat mysql負(fù)載均衡和集群
EHCache - 單落撒旦的日志 - 網(wǎng)易博客
hibernate問題集錦
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服