-->
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.  [ 3 posts ] 
Author Message
 Post subject: @GeneratorIdentifier does not work
PostPosted: Fri Sep 18, 2009 4:44 am 
Newbie

Joined: Fri Sep 18, 2009 4:29 am
Posts: 3
Hi,

I tried to use a custom IdentifierGenerator for entity Id generation on Seam2.1.1.GA on JBoss5.0.1GA.(uses Hibernate 3.3.1.GA as default?)

Unfortunately I cannot apply the Generator using the @GenericGenerator annotation.

Code:
@javax.persistence.Entity
@org.hibernate.annotations.GenericGenerator(
      name="test",
      strategy="com.websein.wcrm.entity.util.MySQLKeyGenerator")
public class TestDing2 {

   @javax.persistence.Id
        @javax.persistence.GeneratedValue(generator="test")
   private Long id;

   public Long getId() {return id;}

   public void setId(Long id) {this.id = id;}
}


Applying it this way produces the following stacktrace.
Code:
org.hibernate.AnnotationException: Unknown Id.generator: test
   at org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:428)
   at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1901)
   at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1279)
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)
   at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:546)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291)
   at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)
        ...


Debugging leads me to the assumption that this annotation simply is not present on my Class at Runtime.

Im working on this Problem for about 2 days and now I have absolutely no more ideas how to solve it. Only thing that works is defining all entites using XML hibernate mapping files. :-(

So did I miss some configuration detail to get this annotation working ?

Any help is appreciated. Ben J.


Top
 Profile  
 
 Post subject: Re: @GeneratorIdentifier does not work
PostPosted: Fri Sep 18, 2009 10:50 am 
Newbie

Joined: Fri Sep 18, 2009 4:29 am
Posts: 3
...
Tracked it down some more, and found out that the
Code:
org.hibernate.cfg.AnnotationBinder

private static void bindGenericGenerators(XAnnotatedElement annotatedElement, ExtendedMappings mappings) {
      ...
                 GenericGenerator defAnn = annotatedElement.getAnnotation( GenericGenerator.class );
                ...
}

becomes always null.
No Matter if Annotation is present on Package Class Method Level.

Stepping deeper ends up in
Code:
org.hibernate.annotations.common.reflection.JavaAnnotationReader

public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
      return element.getAnnotation( annotationType );
   }

The element has a DeclaredAnnotation of Type org.hibernate.annotations.GenericGenerator
and the given "annotationType" is of org.hibernate.annotations.GenericGenerator

It seems as:
Code:
org.hibernate.annotations.GenericGenerator!= org.hibernate.annotations.GenericGenerator



Might this be some kind of Classloader issue ?
Version Conflict .. ?

Is there a way to workaround by adding a GenericGenerator Programmatically at Startup ?

...

---


Top
 Profile  
 
 Post subject: Re: @GeneratorIdentifier does not work
PostPosted: Fri Sep 18, 2009 12:36 pm 
Newbie

Joined: Fri Sep 18, 2009 4:29 am
Posts: 3
Resolved:

Indeed a version problem
Found some older hibernate-annotation.jar in classpath.
An exception which is more related to the problem would be helpful.

cheers
ben


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