Hi
I am trying to migrate an application from JBoss to Websphere 6.1 with Hibernate as JPA provider, i am having problem in persisting an entity.
it looks like the
flush does not work automatically, i went thru many forums and tried different configurations by embedding hibernate provider and thru sharedlib etc.. but no luck,
below is the sample code,
Code:
@Stateless
public class EmpMgr implements IEmpMgr{
@PersistenceContext()
private EntityManager em;
public void addEmp(Emp e){
em.persist(e);
//at the end of this method the emp should have been persisted into database
}
}
@Entity
public class Emp implements Serializable{
@Id
private int id;
private String name;
//getters and setters
}
this business method addEmp() is called from a servlet, what i have found is if i manully place a em.flush() statement at the end of this method it works as expected but that is not required as per the spec and i cannot go and change all my business methods in my application, i am using Hibernate 3.4 as a JPA provider I have changed the class loading to "
Classes loaded with application class loader first" and below is my persistence.xml
Code:
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="DemoUnit" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/demodb</jta-data-source>
<properties>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup" />
<property name ="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory" />
<property name ="hibernate.transaction.flush_before_completion" value="true" />
</persistence-unit>
</persistence>
Quote:
Hibernate and other jar files that i included in the application are
antlr.jar
asm-attrs.jar
asm.jar
cglib.jar
commons-collections.jar
dom4j.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-core.jar
hibernate-entitymanager.jar
javassist.jar
junit.jar
log4j.jar
slf4j-api.jar
slf4j-log4j12.jar
please let me know if anyone got this one working, if so please let me know the details of version of hibernate and the persistence.xml settings.
Thanks
Thiru