I'm trying to use the org.hibernate.ejb.Ejb3Configuration class to configure Hibernate and create an EntityManagerFactory.
Are the properties which you set in that the same as the ones in org.hibernate.cfg.Configuration?
The problem is, Hibernate is not finding my annotated entity beans.
Before, when I used persistence.xml with
Code:
<persistence>
<persistence-unit name="gf">
<description>The base set of green fields' tables</description>
<jta-data-source>java:/GreenFieldsDS</jta-data-source>
<properties>
<property name="hibernate.cache.provider_class" value="org.jboss.ejb3.entity.TreeCacheProviderHook" />
<property name="hibernate.treecache.mbean.object_name" value="jboss.cache:service=EJB3EntityTreeCache" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.ejb.naming_strategy" value="com.fcl.gf.naming.FCLNamingStrategy" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
...
emf = Persistence.createEntityManagerFactory("gf");
it eagerly looked for them on application deployment, and I saw the logging output
Code:
15:12:36,359 INFO [AnnotationBinder] Binding entity from annotated class: com.fcl.greenfield.Language
15:12:36,359 INFO [EntityBinder] Bind entity com.fcl.greenfield.Language on table Language
for each entity binding them to their tables.
Now, application deployment causes verry little logging. And when I try to get an EntityManagerFactory, I do
Code:
String name="GreenFieldsDS";
...
Ejb3Conf = new Ejb3Configuration();
Ejb3Conf.setProperty("hibernate.connection.datasource", "java:/" + name);
Ejb3Conf.setProperty("hibernate.cache.provider_class", "org.jboss.ejb3.entity.TreeCacheProviderHook");
Ejb3Conf.setProperty("hibernate.treecache.mbean.object_name", "jboss.cache:service=EJB3EntityTreeCache");
Ejb3Conf.setProperty("hibernate.show_sql", "true");
Ejb3Conf.setProperty("hibernate.ejb.naming_strategy", "com.fcl.gf.naming.FCLNamingStrategy");
Ejb3Conf.setProperty("hibernate.hbm2ddl.auto", "update");
Logger.info("Ejb3Configuration.createEntityManagerFactory()");
emf = Ejb3Conf.createEntityManagerFactory();
Which I'm hoping has the same effect, but I don't see the binding of annotated entities on deployment, and when I issue a query, it says
Code:
11:18:38,468 WARN [QuerySplitter] no persistent classes found for query class: select c from com.fcl.greenfield.UserGroup as c
How do I configure with org.hibernate.ejb.Ejb3Configuration and get it to scan for annotated entities?