Hi,
I want to persist a POJO class in a stateless session bean. I have read the tutorial (I use a BMT transaction) and I have no exception, BUT the POJO bean is NOT stored in the database at the end.
What can I do to solve this problem ?
Thanks for your help.
My configuration is : Hibernate + Jboss + JDK 1.5
Code in the stateless Session Bean:
Actor actor = null;
UserTransaction tx = null;
try {
actor = new Actor();
actor.setFirstname(firstname);
actor.setName(name);
EntityManagerFactory emf = Persistence.createEntityManagerFactory("dvdstorePU");
EntityManager em = emf.createEntityManager();
tx = (UserTransaction) new InitialContext().lookup("UserTransaction");
tx.begin();
em.persist(actor);
tx.commit();
em.close();
catch(….)
{}
Ejb-jar.xml :
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</session>
</enterprise-beans>
Persistence.xml :
….
<properties>
<property name="hibernate.archive.autodetection" value="class, hbm" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost:3306/dvdstore" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password"
value="system" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup" />
</properties>
…….
|