-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate as JPA provider with WebSphere 7
PostPosted: Sun Mar 06, 2011 12:34 am 
Newbie

Joined: Sat Mar 05, 2011 11:47 pm
Posts: 1
Hi,
I use hibernate 3.2.2 instead of openjpa as JPA 1.0 provider for my EJBs. All hibernate dependencies are put into a WAS shared library and EAR with EJB jars refers them. The application starts well and seems no exceptions are printed in any level. Query entity operations work very well. Whereas I find each update/insert operation cannot be done to database, unless I manually add entityManager.flush() method before each end of my SLSBs. I also tested the same code in JBoss and weblogic, which do not have the problem both. Anyone met the same issue?

Here's my persistence.xml sample, websphere version:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
   version="1.0">
   <persistence-unit name="mes.platform" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>jdbc/mes_platform</jta-data-source>
      <properties>
         <!-- Auto detect annotation model classes -->
         <property name="hibernate.archive.autodetection" value="class" />
         <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
         <property name="hibernate.show_sql" value="false"/>
         <property name="hibernate.format_sql" value="true"/>
         <property name="hibernate.cache.use_query_cache" value="true"/>
         <property name="hibernate.cache.use_second_level_cache" value="true"/>
         <property name="hibernate.cache.region_prefix" value="mes"/>
         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
         <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="jta.UserTransaction" value="java:comp/UserTransaction"/>
         
      </properties>
   </persistence-unit>
</persistence>


And here are my code in SLSB:
Code:
public <T extends Entity> T createEntity(T entity, String sessionId)
  {
    entity.validate();
    String id = entity.getId();
    if ((id == null) || (id.trim().isEmpty())) {
      entity.setId(UUID.randomUUID().toString());
    }
    getEntityManager().persist(entity);

    ///////////////
    //here I should flush it, or the entity created cannot be writen to database eventually
    if(isWebsphere()){
       getEntityManager().flush();
    }
    //////////////

    return entity;
  }



Regards,
Jay


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

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.