三、映身postgresql中serial字段
serial不是一个真实的数据类型,ejb只视其为int,看了以下两文章,还是无法解决。 http://www.ibm.com/developerwork ... openjpa5/index.html http://blog.sina.com.cn/s/blog_5709198d010009po.html http://www.cnblogs.com/earl86/archive/2008/11/06/1666466.html _________________________________________________________ 此问题解决了。http://hi.baidu.com/imake/blog/item/ef32a0cc1397dd1700e92821.html EJB 3中使用Oracle序列的问题 2008年12月05日 22:38 今天在EJB3.0中使用Oracle序列,老报错,错误如下: Caused by: Exception [TOPLINK-7027] (Oracle TopLink Essentials - 2.0 (Build b41-beta2 (03/30/2007))): oracle.toplink.essentials.exceptions.ValidationException Exception Description: The sequence named [USERS_ID_SEQ] is setup incorrectly. Its increment does not match its pre-allocation size. 原来的代码如下: @Id @SequenceGenerator(name = "USER_ID_GEN", sequenceName = "USERS_ID_SEQ") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "USER_ID_GEN") @Column(name="USER_ID", nullable = false) private Long userId; 后来查了资料才知道原来@SequenceGenerator的默认值是50而我的USERS_ID_SEQ设置的是递增1。所以出了错。要设置下allocationSize的值。allocationSize的说明如下: allocationSize (Optional) The amount to increment by when allocating sequence numbers from the sequence. 详细情况见SUN官方文档 改后的代码就是: @Id @SequenceGenerator(name = "USER_ID_GEN", sequenceName = "USERS_ID_SEQ", allocationSize=1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "USER_ID_GEN") @Column(name="USER_ID", nullable = false) private Long userId; |