编程生活

   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  113 随笔 :: 0 文章 :: 18 评论 :: 0 Trackbacks
1.类库:
apache的commons除外
 <classpathentry kind="lib" path="test/lib/hibernate3.jar"/>
 <classpathentry kind="lib" path="test/lib/hibernate-entitymanager.jar"/>
 <classpathentry kind="lib" path="test/lib/jboss-archive-browsing.jar"/>
 <classpathentry kind="lib" path="test/lib/dom4j-1.6.1.jar"/>
 <classpathentry kind="lib" path="test/lib/hibernate-annotations.jar"/>
 <classpathentry kind="lib" path="test/lib/hibernate-commons-annotations.jar"/>
 <classpathentry kind="lib" path="test/lib/javassist.jar"/>
 <classpathentry kind="lib" path="test/lib/cglib-2.1.3.jar"/>
 <classpathentry kind="lib" path="test/lib/asm.jar"/>
 <classpathentry kind="lib" path="test/lib/asm-attrs.jar"/>
 <classpathentry kind="lib" path="test/lib/antlr-2.7.6.jar"/>

2.persistence.xml
 <persistence-unit name="rmp" transaction-type="RESOURCE_LOCAL">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
  <properties>
   <property name="hibernate.show_sql" value="true" />
   <property name="hibernate.format_sql" value="true" />
   <property name="hibernate.dialect"
    value="org.hibernate.dialect.Oracle9iDialect" />
   <property name="hibernate.connection.driver_class"
    value="oracle.jdbc.OracleDriver" />
   <property name="hibernate.connection.url"
    value="jdbc:oracle:thin:@172.16.3.3:1521:ngrm" />
   <property name="hibernate.connection.username" value="xxx" />
   <property name="hibernate.connection.password"
    value="xxx123" />
  </properties>
 </persistence-unit>
3.问题
1.重复属性映射问题,特别烦
@MapSuperClass
public class A {
    @Transistence
    public String getA11()
    }
}

@Entity
@Table(name="...")
public class AA extends A {
   @Transistce
   @Override
   public String getA11() {

   }
}
要定义两次@Transistce
2.new 构造器问题
select distinct new com.xxx.A(a.id, a.ss) from AA a where a.ddd=?1 and ..

为啥一定要采用通用构造器来装载数据?这样最致命的问题是如果一天要改SQL,则要改构造函数,并且如果选出来的字段比较多,构造函数就没法看懂了

完全可以通过缺省构造器实例化,通过其它方式来设值.
其实这一点就是openJPA也没有解决好,主要是不支持别名造成的

3.uuid-hex主键生成器,为啥要用
 @GeneratedValue(generator = "system-uuid")
 @GenericGenerator(name = "system-uuid", strategy = "uuid.hex"),该处要引入一个Hibernate的类,以后就只能在职Hibernate的JPA上跑了,受限
而OpenJPA只用 @GeneratedValue(generator = "uuid-hex")要简单一些

4.优点
1. 验证器部分,但标记也实在太多了,我现在有点讨厌它
posted on 2007-09-30 17:08 wilesun 阅读(3838) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: