-->
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.  [ 4 posts ] 
Author Message
 Post subject: Unknown Id.generator
PostPosted: Tue Feb 08, 2005 6:51 am 
Newbie

Joined: Tue Feb 08, 2005 6:16 am
Posts: 6
I'm currently testing Hibernate3 with annotations and so far things work as expected for my purposes.

The only problem I have found so far is choosing a sequence generator. While the following works if I create the default sequence name called "HIBERNATE_SEQUENCE" and don't define any value for the attribute generator.

Code:
@Column(name = "IDPK", nullable = false)
   @Id(generate=GeneratorType.SEQUENCE)
   public Integer getId() {
      return _id;
   }


As soon as defining a value for generator, hibernate is unable to find the sequence by name, even the default.

Code:
@Column(name = "IDPK", nullable = false)
   @Id(generate=GeneratorType.SEQUENCE, generator = "HIBERNATE_SEQUENCE")
   public Integer getId() {
      return _id;
   }


I could not find any other posts to this problem, therefore I'm not sure if it is a bug or if I'm doing something wrong.

Thanks,
Andreas.


Hibernate version: Hibernate 3.0 beta 2
Database version: DB2 v8.1

Full stack trace of any exception that occurs:
Code:
08.02.2005 11:30:04 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0 beta 2
08.02.2005 11:30:04 org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.password=linux, hibernate.jdbc.batch_versioned_data=true, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.cache.region_prefix=hibernate.test, hibernate.show_sql=true, hibernate.proxool.pool_alias=pool1, hibernate.generate_statistics=true, hibernate.jdbc.use_streams_for_binary=true, hibernate.max_fetch_depth=1, hibernate.connection.pool_size=1, hibernate.connection.username=db2inst1, hibernate.connection.driver_class=com.ibm.db2.jcc.DB2Driver, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.use_sql_comments=true, hibernate.cglib.use_reflection_optimizer=true, hibernate.order_updates=true, hibernate.dialect=org.hibernate.dialect.DB2Dialect, hibernate.connection.url=jdbc:db2://10.200.1.192:50001/test}
08.02.2005 11:30:04 org.hibernate.cfg.Environment <clinit>
INFO: using java.io streams to persist binary types
08.02.2005 11:30:04 org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
08.02.2005 11:30:04 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
08.02.2005 11:30:04 org.hibernate.cfg.AnnotationConfiguration addAnnotatedClass
INFO: Mapping class using metadata: de.eadsysteme.bo.masterdata.User
08.02.2005 11:30:05 org.hibernate.cfg.AnnotationConfiguration addAnnotatedClass
SCHWERWIEGEND: Could not compile the mapping annotations
org.hibernate.AnnotationException: Unknown Id.generator: HIBERNATE_SEQUENCE
   at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:908)
   at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:649)
   at org.hibernate.cfg.AnnotationBinder.processElementsOfAClass(AnnotationBinder.java:484)
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:335)
   at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClass(AnnotationConfiguration.java:44)
   at de.eadsysteme.service.dao.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:41)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:164)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:65)
Exception in thread "main" java.lang.ExceptionInInitializerError
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:164)
   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:65)
Caused by: org.hibernate.AnnotationException: Unknown Id.generator: HIBERNATE_SEQUENCE
   at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:908)
   at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:649)
   at org.hibernate.cfg.AnnotationBinder.processElementsOfAClass(AnnotationBinder.java:484)
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:335)
   at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClass(AnnotationConfiguration.java:44)
   at de.eadsysteme.service.dao.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:41)
   ... 3 more

Process finished with exit code 1


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 09, 2005 3:29 am 
Newbie

Joined: Tue Feb 08, 2005 6:16 am
Posts: 6
I found the solution to my problem by reading the entire documentation and not just bits and pieces!

Sorry,
Andreas.


Top
 Profile  
 
 Post subject: Solution
PostPosted: Thu Dec 22, 2005 5:08 am 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:36 am
Posts: 29
Location: Houston, TX
Can you post the solution here?

_________________
Thank you for your time,

Jason Long
CEO and Chief Software Engineer
BS Physics, MS Chemical Engineering
http://www.supernovasoftware.com
HJBUG Founder and President
http://www.hjbug.com


Top
 Profile  
 
 Post subject: Solution
PostPosted: Thu Dec 22, 2005 5:23 am 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:36 am
Posts: 29
Location: Houston, TX
Code:
@Entity()
@Table(name="t_size")
@SequenceGenerator(name="seq_size", sequenceName="seq_size" )
public class Size implements java.io.Serializable {   
    private Long id;
    @Id(generate=GeneratorType.SEQUENCE, generator="seq_size")
    public Long getId() { return this.id; }
    public void setId(Long id) { this.id = id; }


I needed to add @SequenceGenerator(name="seq_size", sequenceName="seq_size" )

_________________
Thank you for your time,

Jason Long
CEO and Chief Software Engineer
BS Physics, MS Chemical Engineering
http://www.supernovasoftware.com
HJBUG Founder and President
http://www.hjbug.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.