开发者

Ejb3Configuration.addPackage() does not find entities

I want to add known JPA entities programatically when creating EntityManagerFactory. So I have this sequence (Hibernate 3.6)

开发者_运维技巧
 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:

Unknown entity: org.jboss.jawabot.irc.model.IrcMessage

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

Thanks, Ondra

Update: The project is here.

A bit messy because I am trying few tricks in that.

And note, entities from the "core" module (jar) of the app are picked up.


The anwser is, the purpose of addPackage() is only to tell Hibernate to take given package's annotations into account, not to load it's Entities.

More, Ejb3Configuration will be deprecated for 4.0 in favor of EntityManagerFactoryBuilder, see https://hibernate.onjira.com/browse/HHH-6159 .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜