`
xiuying
  • 浏览: 541756 次
  • 性别: Icon_minigender_1
  • 来自: 福建
社区版块
存档分类
最新评论

关于annotations

    博客分类:
  • java
阅读更多

annotations

1  class
@Entity
@Table(name="GZL_ACTION_DEFINE")
2 property
加在getter方法前,简单值属性也可以不加
getter、setter、is方法会自动映射为column
3 用@Transient
取消当前属性的映射
4
@OneToMany(mappedBy="trans",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
    @OrderBy("sortFlag")

@OneToMany
    @JoinColumn(name="FK_desctransid")
    @OrderBy("sortFlag")

@Id
    @Column(name = "id")
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")

@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
    @JoinColumn(name="flowDefineId")
    @ForeignKey(name="FK_FD_AD")
5 list必须有排序字段,而且是数字类型
@OrderBy("sortFlag")
6 一个entity有多个集合
@OneToMany
    @JoinColumn(name="FK_desctransid")
    @IndexColumn(name="sortFlag")
7 单向关联
@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
    @JoinTable(
            name="GZL_TCond_DESA",//表名
            joinColumns = { @JoinColumn( name="condition_id") },//当前对象的关联id
            inverseJoinColumns = @JoinColumn( name="actionDefine_id")//关联表的id
    )
    @IndexColumn(name="sortFlag")

8 manytoone
使用继承关系,多个类都在一张表中时,one端集合关联子类时
父类的get<Object>方法需要指明@Transient
否则会出现
Could not determine type for的异常
 
9
CascadeType.PERSIST (级联新建)
CascadeType.REMOVE (级联删除)
CascadeType.REFRESH (级联刷新)
CascadeType.MERGE (级联更新)中选择一个或多个。
还有一个选择是使用CascadeType.ALL ,表示选择全部四项 <property name="hibernateProperties">
   
  </property>

分享到:
评论
1 楼 xiuying 2007-08-03  
10在xml中的配置

<bean id="sessionFactory"  class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
  <property name="dataSource" ref="dataSource"/>
    <property name="annotatedClasses">
     <list>
        <value></value>
        </list>
   </property>
 
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">

                 org.hibernate.dialect.OracleDialect

               </prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.hbm2ddl.auto">update</prop> //三种值 (create update null)
    <prop key="hibernate.jdbc.batch_size">0</prop>
   </props>
  </property>

相关推荐

    annotations-13.0-API文档-中文版.zip

    赠送jar包:annotations-13.0.jar; 赠送原API文档:annotations-13.0-javadoc.jar; 赠送源代码:annotations-13.0-sources.jar; 赠送Maven依赖信息文件:annotations-13.0.pom; 包含翻译后的API文档:...

    swagger-annotations-2.1.2-API文档-中文版.zip

    赠送jar包:swagger-annotations-2.1.2.jar; 赠送原API文档:swagger-annotations-2.1.2-javadoc.jar; 赠送源代码:swagger-annotations-2.1.2-sources.jar; 赠送Maven依赖信息文件:swagger-annotations-2.1.2....

    annotations-23.0.0-API文档-中文版.zip

    赠送jar包:annotations-23.0.0.jar; 赠送原API文档:annotations-23.0.0-javadoc.jar; 赠送源代码:annotations-23.0.0-sources.jar; 赠送Maven依赖信息文件:annotations-23.0.0.pom; 包含翻译后的API文档:...

    swagger-annotations-1.6.2-API文档-中文版.zip

    赠送jar包:swagger-annotations-1.6.2.jar; 赠送原API文档:swagger-annotations-1.6.2-javadoc.jar; 赠送源代码:swagger-annotations-1.6.2-sources.jar; 赠送Maven依赖信息文件:swagger-annotations-1.6.2....

    swagger-annotations-1.5.20-API文档-中文版.zip

    赠送jar包:swagger-annotations-1.5.20.jar; 赠送原API文档:swagger-annotations-1.5.20-javadoc.jar; 赠送源代码:swagger-annotations-1.5.20-sources.jar; 赠送Maven依赖信息文件:swagger-annotations-...

    audience-annotations-0.5.0-API文档-中英对照版.zip

    赠送jar包:audience-annotations-0.5.0.jar; 赠送原API文档:audience-annotations-0.5.0-javadoc.jar; 赠送源代码:audience-annotations-0.5.0-sources.jar; 赠送Maven依赖信息文件:audience-annotations-...

    开发工具 jackson-annotations-2.8.6

    开发工具 jackson-annotations-2.8.6开发工具 jackson-annotations-2.8.6开发工具 jackson-annotations-2.8.6开发工具 jackson-annotations-2.8.6开发工具 jackson-annotations-2.8.6开发工具 jackson-annotations-...

    swagger-annotations-1.5.24-API文档-中文版.zip

    赠送jar包:swagger-annotations-1.5.24.jar; 赠送原API文档:swagger-annotations-1.5.24-javadoc.jar; 赠送源代码:swagger-annotations-1.5.24-sources.jar; 赠送Maven依赖信息文件:swagger-annotations-...

    jackson-annotations-2.9.0-API文档-中文版.zip

    赠送jar包:jackson-annotations-2.9.0.jar; 赠送原API文档:jackson-annotations-2.9.0-javadoc.jar; 赠送源代码:jackson-annotations-2.9.0-sources.jar; 赠送Maven依赖信息文件:jackson-annotations-2.9.0....

    j2objc-annotations-1.3-API文档-中文版.zip

    赠送jar包:j2objc-annotations-1.3.jar; 赠送原API文档:j2objc-annotations-1.3-javadoc.jar; 赠送源代码:j2objc-annotations-1.3-sources.jar; 赠送Maven依赖信息文件:j2objc-annotations-1.3.pom; 包含...

    jcip-annotations-1.0

    jcip-annotations-1.0

    error_prone_annotations-2.10.0-API文档-中英对照版.zip

    赠送jar包:error_prone_annotations-2.10.0.jar; 赠送原API文档:error_prone_annotations-2.10.0-javadoc.jar; 赠送源代码:error_prone_annotations-2.10.0-sources.jar; 赠送Maven依赖信息文件:error_prone_...

    jackson-annotations-2.11.4-API文档-中文版.zip

    赠送jar包:jackson-annotations-2.11.4.jar; 赠送原API文档:jackson-annotations-2.11.4-javadoc.jar; 赠送源代码:jackson-annotations-2.11.4-sources.jar; 赠送Maven依赖信息文件:jackson-annotations-...

    j2objc-annotations-1.1-API文档-中文版.zip

    赠送jar包:j2objc-annotations-1.1.jar; 赠送原API文档:j2objc-annotations-1.1-javadoc.jar; 赠送源代码:j2objc-annotations-1.1-sources.jar; 赠送Maven依赖信息文件:j2objc-annotations-1.1.pom; 包含...

    error_prone_annotations-2.3.2-API文档-中文版.zip

    赠送jar包:error_prone_annotations-2.3.2.jar; 赠送原API文档:error_prone_annotations-2.3.2-javadoc.jar; 赠送源代码:error_prone_annotations-2.3.2-sources.jar; 赠送Maven依赖信息文件:error_prone_...

    animal-sniffer-annotations

    animal-sniffer-annotations

    hadoop-annotations-2.7.3-API文档-中文版.zip

    赠送jar包:hadoop-annotations-2.7.3.jar; 赠送原API文档:hadoop-annotations-2.7.3-javadoc.jar; 赠送源代码:hadoop-annotations-2.7.3-sources.jar; 赠送Maven依赖信息文件:hadoop-annotations-2.7.3.pom;...

    hibernate-annotations-3.4.0.GA

    《Hibernate Annotations 3.4.0.GA:深入理解与应用》 Hibernate是Java领域中广泛应用的对象关系映射(ORM)框架,它极大地简化了数据库操作,使得开发者可以使用面向对象的方式来处理数据。而Hibernate ...

    error_prone_annotations-2.2.0-API文档-中文版.zip

    赠送jar包:error_prone_annotations-2.2.0.jar; 赠送原API文档:error_prone_annotations-2.2.0-javadoc.jar; 赠送源代码:error_prone_annotations-2.2.0-sources.jar; 赠送Maven依赖信息文件:error_prone_...

    error_prone_annotations-2.0.18-API文档-中文版.zip

    赠送jar包:error_prone_annotations-2.0.18.jar; 赠送原API文档:error_prone_annotations-2.0.18-javadoc.jar; 赠送源代码:error_prone_annotations-2.0.18-sources.jar; 赠送Maven依赖信息文件:error_prone_...

Global site tag (gtag.js) - Google Analytics