我们处于将休眠模式从 3.6 升级到 4.1.9 的模式,我遇到了一个错误
[#|2013-01-14T18:33:46.519+0530|INFO|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=122;_ThreadName=Thread-3;|2013-01-14 18:33:46,518 [http-thread-pool-8080(5)] ERROR envId{} - sesId{} - com.spmsoftware.webframework.exception.ExceptionHandlerUtil[31]-Unhandled exception! org.hibernate.AssertionFailure: getGeneratedKeys() support is not enabled at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.checkAutoGeneratedKeysSupportEnabled(StatementPreparerImpl.java:93) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:112) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.id.SequenceIdentityGenerator$Delegate.prepare(SequenceIdentityGenerator.java:106) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:55) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2936) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3447) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:203) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:183) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:167) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:320) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:126) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:78) ~[hibernate-entitymanager-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:208) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:151) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:78) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:843) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:818) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:822) ~[hibernate-core-4.1.9.Final.jar:4.1.9.Final] at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:865) ~[hibernate-entitymanager-4.1.9.Final.jar:4.1.9.Final]
当我尝试持久化具有以下定义的休眠实体时会出现此错误
@Entity
@Table(name = "ACCESS")
@GenericGenerator(name = "auth-generator",
strategy = "sequence-identity",
parameters = @org.hibernate.annotations.Parameter(name = "sequence", value = "ACCESS_SEQ"))
public class Access implements Identifiable {
private Long id;
@Id
@GeneratedValue(generator = "auth-generator")
@Column(name = "ROW_IDENTIFIER", nullable = false)
public Long getId() {
return id;
}
}
在比较 3.6 的休眠源代码时,我看到在为 SequenceIdentityGenerator 创建准备好的语句时,休眠不检查“hibernate.jdbc.use_get_generated_keys”(AbstractBatcher - 506)和版本 4.1.9(StatementPreparerImpl - 112)。
因此,我们的应用程序升级失败。知道这种变化背后的原因是什么吗?