-->
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.  [ 4 posts ] 
Author Message
 Post subject: Autodetection in Maven/Eclipse project
PostPosted: Wed May 06, 2009 6:55 pm 
Newbie

Joined: Wed Apr 15, 2009 4:43 am
Posts: 5
I have a very peculiar problem:

I'm using Hibernate in Maven based project inside of Eclipse, and I'm checking Hibernate console configurations in JBoss's Hibernate Tools plugin.

I have identical configuration for two projects:
Code:
<persistence-unit name="mogulhibernate04">         
   <provider>org.hibernate.ejb.HibernatePersistence</provider>
   <class>com.mogul.hibernatetutorial04.model.User2</class>
   <properties>    
        <!-- mappings -->      
      <property name="hibernate.archive.autodetection" value="class"/>

In one project I have all classes with annotations listed/found in the Hibernate console (created in the Eclipse's Hibernate perspective).
And in the second it's only one explicitly specified that is listed/found!

I can't see no obvious reason for not finding all annotated classes in the second project.

Any ideas? Classpath, maybe?


Top
 Profile  
 
 Post subject: Re: Autodetection in Maven/Eclipse project
PostPosted: Fri May 08, 2009 12:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
For Hibernate to automatically pick up entities they need to be in a standard packaged persistence unit.

Meaning META-INF/persistence.xml should be next to the classes in the classpath.

Otherwise they won't be considered as entities.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Autodetection in Maven/Eclipse project
PostPosted: Sat May 09, 2009 6:04 am 
Newbie

Joined: Wed Apr 15, 2009 4:43 am
Posts: 5
Problem solved. But I'm not sure how.

It was some Eclipse issue, because when deployed to Jetty server the persistence unit did found all entities inside the project. And in the same time the JBoss Tools (Hibernate Tools) plugin didn't.

The next day, in Eclipse it just worked!?!
I guess it's something about Eclipse's internal configuration on workspaces, classpaths, cashing of metadata, etc.
Which is even more stranger to me 'cause I did rebooted on the previous day too.


Top
 Profile  
 
 Post subject: Re: Autodetection in Maven/Eclipse project
PostPosted: Sat May 09, 2009 8:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
My guess is that when you deployed the META-INF/persistence.xml where the first time that file entered into your classpath explaining why it works now, but not before.

_________________
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.  [ 4 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.