-->
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: I doubt that the Hibernate Console works with annotated POJO
PostPosted: Sun Apr 24, 2011 5:42 pm 
Newbie

Joined: Mon Dec 21, 2009 3:20 pm
Posts: 2
I' m using the Hibernate 3.2.4 GA console and I can't see where it can work at all with my annotated entity classes. The console always wants a hibernate.hbm.xml file and there doesn't seem to be a way to add AnnotationConfiguration information there - or I can't find an example of just WHERE one would put their annotation ifnormation. I tried the old-school reverse engineered building of the .hbm.xml descriptors for each of my 100 classes, but that was a failure as well (50% of the classes could not be found, even though they ALL reside in the SAME classpath - but that's a whole different issue).

Please show me an example, or a recent web link, or a tutorial that spells out how to operate the Hibernate Console with annotated POJO classes.

In summary, how do I take something like this (having a composite-id):
Code:
...
// Generated Apr 24, 2011 2:31:22 PM by Hibernate Tools 3.2.4.GA

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
* Testscratch generated by hbm2java
*/
@Entity
@Table(name = "testscratch", catalog = "database")
public class Testscratch implements java.io.Serializable {

   private TestscratchId id;

   public Testscratch() {
   }

   public Testscratch(TestscratchId id) {
      this.id = id;
   }

   @EmbeddedId
   @AttributeOverrides( {
         @AttributeOverride(name = "name", column = @Column(name = "name", nullable = false, length = 100)),
         @AttributeOverride(name = "mobile", column = @Column(name = "mobile", nullable = false, length = 100)),
         @AttributeOverride(name = "encname", column = @Column(name = "encname", nullable = false, length = 100)),
         @AttributeOverride(name = "encmobile", column = @Column(name = "encmobile", nullable = false, length = 100)) })
   public TestscratchId getId() {
      return this.id;
   }
     
        // TestscratchId is just a composite-id POJO
   public void setId(TestscratchId id) {
      this.id = id;
   }

}


And configure it under the Hibernate Console to eventually run the HQL Editor on it?


Top
 Profile  
 
 Post subject: Re: I doubt that the Hibernate Console works with annotated POJO
PostPosted: Fri Apr 29, 2011 10:48 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I assume you use JPA ? Then simply choose JPA when you create the Console Configuration.

Your project will need a META-INF/persistence.xml to tell Hibernate EntityManager that it needs to scan for entities.

_________________
Max
Don't forget to rate


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.