-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Websphere 6.1 + EJB 3.0 pack + Hibernate 3.4 as JPA provider
PostPosted: Wed Jan 20, 2010 2:14 pm 
Newbie

Joined: Wed Jan 20, 2010 1:52 pm
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: Websphere 6.1 + EJB 3.0 pack + Hibernate 3.4 as JPA provider
PostPosted: Wed Jan 20, 2010 4:38 pm 
Newbie

Joined: Wed Jan 20, 2010 1:52 pm
Posts: 3
Removed property hibernate.transaction.factory_class and it works now,
<property name ="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory" />

Thanks


Last edited by jmailz@yahoo.com on Wed Jan 20, 2010 6:43 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Websphere 6.1 + EJB 3.0 pack + Hibernate 3.4 as JPA provider
PostPosted: Wed Jan 20, 2010 6:41 pm 
Newbie

Joined: Wed Jan 20, 2010 1:52 pm
Posts: 3
At last I made this working, i removed the below property from persistence.xml and it worked.

<property name ="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory" />

my current working persistence.xml is,
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.transaction.manager_lookup_class" value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup" />   
    </properties>
</persistence-unit>
   
</persistence>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.