全文预览

hibernate_-annotations_中文帮助文档

上传者:幸福人生 |  格式:doc  |  页数:77 |  大小:560KB

文档介绍
nth","day"})})上面这个例子中,在month和day这两个字段上定义唯一约束.注意columnNames数组中的值指的是逻辑列名.Hibernate在NamingStrategy的实现中定义了逻辑列名.默认的EJB3命名策略将物理字段名当作逻辑字段名来使用.注意该字段名和它对应的属性名可能不同(如果字段名是显式指定的话).除非你重写了NamingStrategy,否则不用担心这些区别..2.2.1.2.乐观锁定版本控制你可以在实体bean中使用@Version注解,通过这种方式可添加对乐观锁定的支持:@lassFlightimplementsSerializable{...@Version@Column(name="OPTLOCK")publicIntegergetVersion(){...}}上面这个例子中,version属性将映射到OPTLOCK列,entitymanager使用该字段来检测更新冲突(防止更新丢失,mit-wins策略).根据EJB3规范,version列可以是numeric类型(推荐方式)也可以是timestamp类型.Hibernate支持任何自定义类型,只要该类型实现了UserVersionType.2.2.2.映射简单属性2.2.2.1.ontransientproperty(fieldormethod)ofanentitybeanisconsideredpersistent,unlessyouannotateitas@Transient.Nothavinganannotationforyourpropertyisequivalenttotheappropriate@Basicannotation.The@Basicannotationallowsyoutodeclarethefetchingstrategyforaproperty:

收藏

分享

举报
下载此文档