[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Is it possible to use Hibernate persistent classes from EJB
dimar1975
do-not-reply at jboss.com
Tue May 26 03:13:37 EDT 2009
Hi all,
I have an Enterprise application made up of a :
-WAR archive
-HAR archive (Hibernate persistent classes)
now I'm going to add an EJB JAR (A Session Bean). I'm trying to use Hibernate persistent classes from the EJB however I've found some problems:
@Stateless
| public class ManagerBean implements ManagerLocal {
|
| @PersistenceUnit(unitName="unit1") SessionFactory factory;
|
| public void executeQuery() {
|
| // Factory is correctly injected here
| System.out.println("Factory is "+factory);
|
| // TransactionException
| // hsession.beginTransaction();
|
| Session hsession = factory.openSession();
|
| List <Data> result = hsession.createQuery("from com.igv.Data").list();
|
| .....
| }
The first problem I've met is that I cannot start a Transaction using Hibernate otherwise JBoss issues "javax.ejb.EJBException: org.hibernate.TransactionException: Could not register synchronization for container transaction".
This is I guess because the EJB is container managed transaction so I cannot use an external transaction manager. Ok.
Commenting that line however leads to another problem:
08:55:27,982 WARN [QuerySplitter] no persistent classes found for query class: from com.igv.Data
So my question is: can you actually use Hibernate persistent classes from an EJB or do you need to port Hibernate classes to Entity Beans ?
Thanks
Marco
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4233177#4233177
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4233177
More information about the jboss-user
mailing list