Hi all! I'm trying to specify a GenericGenerator at package-level but, no matter what I try I always end up with the same exception.
package-info.javaCode:
@GenericGenerator(
name = "mygenerator",
strategy = "org.hibernate.id.enhanced.TableGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "MY_SEQUENCE"),
@Parameter(name = "initial_value", value = "1000"),
@Parameter(name = "optimizer", value = "pooled"),
@Parameter(name = "increment_size", value = "10")
}
)
package com.somepackage.domain;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
My EntityCode:
package com.somepackage.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
@Entity
public class Account{
@Id
@GeneratedValue(generator = "mygenerator")
private Long id;
@NotNull
private String name;
//...
}
The ExceptionQuote:
Caused by: org.hibernate.AnnotationException: Unknown Id.generator: mygenerator
at org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:639)
at org.hibernate.cfg.AnnotationBinder.processId(AnnotationBinder.java:2159)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2065)
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:767)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:686)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3540)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3494)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1379)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1784)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1868)
I'm using Tomcat7 and OpenJDK7
Regards!