-->
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.  [ 2 posts ] 
Author Message
 Post subject: Unknown Id.generator
PostPosted: Fri Mar 17, 2006 5:29 am 
Beginner
Beginner

Joined: Mon Dec 05, 2005 4:15 am
Posts: 36
I have a problem with the ID sequence generators (Oracle database).

I use Hibernate 3.1.
The Id column is so decrared:
Code:
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "RNSEQUENZ")
    public String getRN() {
        return RN;
    }
    public void setRN(String RN) {
        this.RN = RN;
    }


I have the sequence with this name, the SQL: "select RNSEQUENZ.nextval from dual" returns the next value of sequence.

But my application throws an exception:

Code:
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.AnnotationException: Unknown Id.generator: RNSEQUENZ
        at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:173)
        at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:103)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
        at konto.ejb3.TestKontoEJB3.main(TestKontoEJB3.java:29)

Caused by: org.hibernate.AnnotationException: Unknown Id.generator: RNSEQUENZ
        at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1595)
        at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1065)
        at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:629)
        at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:276)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:210)
        at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:997)
        at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:722)
        at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:161)
        at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:567)
        at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:118)
        at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:165)



Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 18, 2006 4:26 am 
Beginner
Beginner

Joined: Wed Aug 24, 2005 5:32 am
Posts: 23
Hi,

Using
Code:
@Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "RNSEQUENZ")


is not enough to access the "RNSEQUENZ" sequence. The value of the 'generator' attribute is some kind of a "logical name". You have to declare it using a @SequenceGenerator annotation:

Code:
@javax.persistence.SequenceGenerator(
name="<logical sequence name>",
sequenceName="<actual database object name>")
@Id @GeneratedValue(strategy=GeneratorType.SEQUENCE, generator="<logical sequence name>")


Eyal Lupu


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

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.