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