-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate 4 - getGeneratedKeys() support is not enabled
PostPosted: Tue Jan 15, 2013 9:14 am 
Newbie

Joined: Fri Jun 30, 2006 12:11 am
Posts: 7
Location: Pune
We are in a mode of upgrading hibernate from version 3.6 to 4.1.9 and I am facing an error

Code:
[#|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]


This error is seen when I try to persist a hibernate entity which has the following definition
Code:
@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;
    }
}



On comparing hibernate source code for 3.6 I saw that while creating a prepared statement for SequenceIdentityGenerator hibernate does NOT check for "hibernate.jdbc.use_get_generated_keys" (AbstractBatcher - 506) and for version 4.1.9 it does (StatementPreparerImpl - 112).

Due to this, our application fails on upgrade. Any idea on what is the reason behind this change?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.