-->
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: Ejb3Configuration.addPackage() does not find entities.
PostPosted: Thu Jul 21, 2011 8:30 am 
Newbie

Joined: Sun Aug 16, 2009 11:48 am
Posts: 4
Hi everyone,

I want to add known JPA entities programatically when creating EntityManagerFactory.
So I have this sequence (Hibernate 3.6)
Code:
            Ejb3Configuration ejbConf = new Ejb3Configuration();
            ejbConf.configure("TestPU", null);
            ejbConf.addPackage("org.jboss.jawabot.irc.ent");
            ejbConf.addPackage("org.jboss.jawabot.irc.model");
            emf = ejbConf.buildEntityManagerFactory();

I also tried calling addPackage()'s before configure().
Adding packages is fine.
However, Hibernate does not find the entities. When I persist it, I get:
Quote:
Unknown entity: org.jboss.jawabot.irc.model.IrcMessage

What's wrong? How do I make Hbernate recognize entities from those packages?

Thanks,
Ondra


Top
 Profile  
 
 Post subject: Re: Ejb3Configuration.addPackage() does not find entities.
PostPosted: Thu Jul 21, 2011 7:31 pm 
Newbie

Joined: Sun Oct 31, 2010 5:18 pm
Posts: 4
When I pass the class to addAnnotatedClass(), it works.
Which means Hibernate fails to scan the package.


Top
 Profile  
 
 Post subject: Re: Ejb3Configuration.addPackage() does not find entities.
PostPosted: Thu Jul 21, 2011 8:02 pm 
Newbie

Joined: Sun Oct 31, 2010 5:18 pm
Posts: 4
Ok, seems like I get it - addPackage() is not supposed to scan packages for entities, only take package's annotations into account.

Maybe that could be noted in javadoc.
http://docs.jboss.org/hibernate/core/3. ... .String%29

Created a docs jira - https://hibernate.onjira.com/browse/HHH-6466 Improve javadoc of Ejb3Configuration


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.