-->
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: Hibernate Annotation Configuration
PostPosted: Mon Mar 07, 2011 12:44 pm 
Newbie

Joined: Mon Mar 07, 2011 12:32 pm
Posts: 2
Hello all,

I am using the AnnotationConfiguration object, for the first time, to startup hibernate. The following code does that:

sessionFactory = new AnnotationConfiguration()
.addPackage("com.entity")
.addAnnotatedClass(Address.class)
.addAnnotatedClass(Contact.class)
.configure()
.buildSessionFactory();

The Address and Contact entities are annotated and are in the com.entity package. The hibernate.cfg.xml file has the following entries:

<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/vj_test</property>
<property name="hibernate.connection.username">vj_test</property>
<property name="hibernate.connection.password">vj_test</property>
<property name="hibernate.hbm2ddl.auto">create</property>
</session-factory>
</hibernate-configuration>

When I start the server, I can see that the db connection is obtained, but the two tables (Address and Contact) are not created. I gave hibernate.hbm2dll.auto to "true" in the config file. I also see a WARN message in the logs like this:

16:42:29,809 WARN [AnnotationBinder:222] Package not found or wo package-info.java: com.entity

What am I doing wrong here? Please help...i'm stuck with this issue for the last 3 days :(.

thanks


Top
 Profile  
 
 Post subject: Re: Hibernate Annotation Configuration
PostPosted: Mon Mar 07, 2011 1:08 pm 
Newbie

Joined: Mon Mar 07, 2011 12:32 pm
Posts: 2
Friends,

I figured out what the issue was: I was using org.hibernate.annotations.Entity for the @Entity annotation. I changed it to javax.persistence.Entity and it worked like a charm :)

thanks


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.