-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problem / Question: EJB 3 with CMT and Hibernate 3.4 GA JPA
PostPosted: Fri Oct 03, 2008 11:20 am 
Newbie

Joined: Tue Aug 26, 2008 7:01 am
Posts: 12
Location: Zuerich, Switzerland
Hi all

I am new to to Hibernate and JPA and trying some examples for an evaluation of JPA in a larger project. So the question might be very basic for you but I'ld apreciate some help.

What I am trying to do is:
EJB 3 with CMT and Hibernate JPA.


Problem / Question
In a transactional method of a session bean I read an Entity and change it. Hibernate is only updating the DB when I'am explicitely calling flush.

I thougt that with JPA end EJB 3 CMT the DB update is done automatically on commit without that I am calling any method to indicate so, also not flush. Am I wrong? If yes what would be a correct way to do it?

Below you'll find my persistence.xml and the bean code. The method in question is formatted bold.

Environment
Hibernate Version: 3.4 GA
DB: Pointbase
J2EE Server: Weblogic 10.3
JDK 1.6


Peristence.xml
Code:
<?xml version="1.0"?>

<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">

    <!-- TODO switch to DataSource -->
    <persistence-unit name="MedRec" transaction-type="JTA">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>jdbc/MedRecGlobalDataSourceXA</jta-data-source>
        <class>com.bea.medrec.model.Address</class>
        <class>com.bea.medrec.model.Administrator</class>
        <class>com.bea.medrec.model.BaseEntity</class>
        <class>com.bea.medrec.model.PersonName</class>
        <class>com.bea.medrec.model.Patient</class>
        <class>com.bea.medrec.model.Physician</class>
        <class>com.bea.medrec.model.Prescription</class>
        <class>com.bea.medrec.model.Record</class>
        <class>com.bea.medrec.model.RegularUser</class>
        <class>com.bea.medrec.model.User</class>
        <class>com.bea.medrec.model.VersionedEntity</class>
        <class>com.bea.medrec.model.VitalSigns</class>
        <properties>
            <!-- SQL stdout logging -->
             <property name="hibernate.show_sql" value="true"/>
             <property name="hibernate.format_sql" value="true"/>
             <property name="use_sql_comments" value="true"/>
             
             <!-- to prevent the ClassDefNotFound problem with weblogic -->
         <property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/>

             <property name="hibernate.c3p0.min_size" value="5"/>
             <property name="hibernate.c3p0.max_size" value="20"/>
             <property name="hibernate.c3p0.timeout" value="300"/>
             <property name="hibernate.c3p0.max_statements" value="50"/>
           <property name="hibernate.c3p0.idle_test_period" value="3000"/>

         <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
         <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.CMTTransactionFactory"/>
             <property name="hibernate.dialect" value="org.hibernate.dialect.PointbaseDialect"/>
        </properties>
    </persistence-unit>
</persistence>


Bean Implementation

Code:
package com.bea.medrec.repository.impl;

import java.util.List;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.bea.medrec.model.Patient;
import com.bea.medrec.repository.PatientRepository;

/**
* @author Copyright (c) 2007 by BEA Systems. All Rights Reserved.
* @author <a href="mailto:shli@bea.com">Li Shen</a>
*/
@Stateless
@Remote(PatientRepository.class)
public class PatientRepositoryImpl implements PatientRepository {

    // TODO customize persistence unit?
    @PersistenceContext(name = "MedRec")
    private EntityManager entityManager;


@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public Patient approvePatient(Long patientId) {
Patient patient = entityManager.find(Patient.class, patientId);
patient.approve();
entityManager.flush();
return patient;
}

Code:
    protected int countByProperties(String namedQuery, Property... properties) {
        return countByProperties(namedQuery, properties);
    }

    public int countBySsn(String ssn) {
        String query = "Patient.countPatientBySsn";
        return countByProperties(query, new Property("ssn", ssn));
    }

    public int countBySsnAndId(String ssn, Long id) {
        String query = "Patient.countPatientBySsnAndId";
        return countByProperties(query, new Property("ssn", ssn), new Property("id", id));
    }

    public int countByUsername(String username) {
        return countByProperties(getQueryForCountByUsername(), new Property("username", username));
    }

    public int countByUsernameAndPassword(String username, String password) {
        return countByProperties("Patient.countPatientByUsernameAndPassword", new Property("username", username),
                                 new Property("password", password));
    }

    public int countByUsernameAndPasswordAndStatus(String username, String password, Patient.Status status) {
        String query = "Patient.countPatientByUsernameAndPasswordAndStatus";
        return countByProperties(query, new Property("username", username), new Property("password", password),
                                 new Property("status", status.toString()));
    }

    private Query createNamedQuery(String namedQuery, Property... propertyValues) {
        Query query = getEntityManager().createNamedQuery(namedQuery);
        int i = 1;
        for (Object propertyValue : propertyValues) {
            Property property = (Property) propertyValue;
            query.setParameter(property.name, property.value);
            i++;
        }
        return query;
    }

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void delete(Long id) {
        // TODO maybe use a query instead
        entityManager.remove(find(id));
    }

    public Patient find(Long id) {
        return entityManager.find(Patient.class, id);
    }

    public List<Patient> findByLastNameAndStatus(String lastName, Patient.Status status) {
        String query = "Patient.findPatientByLastNameAndStatus";
        return findByProperties(query, new Property("lastName", lastName),
                                new Property("status", status.toString()));
    }

    protected List<Patient> findByProperties(String namedQuery, Property... properties) {
        return createNamedQuery(namedQuery, properties).getResultList();
    }

    public Patient findBySsnAndStatus(String ssn, Patient.Status status) {
        String query = "Patient.findPatientBySsnAndStatus";
        return findByUniqueProperties(query, new Property("ssn", ssn), new Property("status", status.toString()));
    }

    public List<Patient> findByStatus(Patient.Status status) {
        return createNamedQuery("Patient.findPatientByStatus", new Property("status", status.toString()))
            .getResultList();
    }

    protected Patient findByUniqueProperties(String namedQuery, Property... properties) {
        try {
            return (Patient) createNamedQuery(namedQuery, properties).getSingleResult();
        }
        catch (NoResultException e) {
            return null;
        }
    }

    protected Patient findByUniqueProperty(String namedQuery, String propertyName, Object propertyValue) {
        return findByUniqueProperties(namedQuery, new Property(propertyName, propertyValue));
    }

    public Patient findByUsernameAndPassword(String username, String password) {
        return findByUniqueProperties("Patient.findPatientByUsernameAndPassword",
                                      new Property("username", username), new Property("password", password));
    }

    public Patient findByUsernameAndPasswordAndStatus(String username, String password, Patient.Status status) {
        String query = "Patient.findPatientByUsernameAndPasswordAndStatus";
        return findByUniqueProperties(query, new Property("username", username),
                                      new Property("password", password), new Property("status", status.toString()));
    }

    protected EntityManager getEntityManager() {
        return entityManager;
    }

    protected String getQueryForCountByUsername() {
        return "Patient.countPatientByUsername";
    }

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void save(Patient entity) {
        entityManager.persist(entity);
    }

    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public Patient update(Patient entity) {
        Patient retVal = entityManager.merge(entity);
        //entityManager.flush();
        return retVal;
    }

    class Property {

        public String name;

        public Object value;

        public Property(String name, Object value) {
            this.name = name;
            this.value = value;
        }
    }
}


Top
 Profile  
 
 Post subject: The Entitiy beans code
PostPosted: Sat Oct 04, 2008 3:20 am 
Newbie

Joined: Tue Aug 26, 2008 7:01 am
Posts: 12
Location: Zuerich, Switzerland
I just saw that I've forgotten to post the Entity Code:

Code:
package com.bea.medrec.model;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.Date;
import java.util.List;

/**
* @author Copyright (c) 2007 by BEA Systems. All Rights Reserved.
* @author <a href="mailto:shli@bea.com">Li Shen</a>
*/
@Entity
@Table(name = "patients"/*, uniqueConstraints = {@UniqueConstraint(columnNames = {"email", "username", "ssn"})}*/)
@NamedQueries({
@NamedQuery(name = "Patient.countPatientByUsernameAndPasswordAndStatus",
        query = "SELECT COUNT(p) FROM Patient p WHERE p.username = :username AND p.password = :password AND p.status = :status"),
@NamedQuery(name = "Patient.countPatientByUsernameAndPassword",
        query = "SELECT COUNT(p) FROM Patient p WHERE p.username = :username AND p.password = :password"),
@NamedQuery(name = "Patient.countPatientByUsername",
        query = "SELECT COUNT(p) FROM Patient p WHERE p.username = :username"),
@NamedQuery(name = "Patient.countPatientBySsnAndId",
        query = "SELECT COUNT(p) FROM Patient p WHERE p.ssn = :ssn AND p.id <> :id"),
@NamedQuery(name = "Patient.countPatientBySsn",
        query = "SELECT COUNT(p) FROM Patient p WHERE p.ssn = :ssn"),
@NamedQuery(name = "Patient.findPatientByStatus",
        query = "SELECT p FROM Patient p WHERE p.status = :status"),
@NamedQuery(name = "Patient.findPatientBySsnAndStatus",
        query = "SELECT p FROM Patient p WHERE p.ssn = :ssn AND p.status = :status"),
@NamedQuery(name = "Patient.findPatientByLastNameAndStatus",
        query = "SELECT p FROM Patient p WHERE p.name.lastName = :lastName AND p.status = :status"),
@NamedQuery(name = "Patient.findPatientByUsernameAndPasswordAndStatus",
        query = "SELECT p FROM Patient p WHERE p.username = :username AND p.password = :password AND p.status = :status"),
@NamedQuery(name = "Patient.findPatientByUsernameAndPassword",
        query = "SELECT p FROM Patient p WHERE p.username = :username AND p.password = :password")
        })
public class Patient extends RegularUser {

    private static final long serialVersionUID = 313728838021028177L;

    private Date dob;

    @Enumerated(EnumType.STRING)
    private Gender gender;

    private String ssn;

    private Address address = new Address();

    @Enumerated(EnumType.STRING)
    private Patient.Status status = Patient.Status.REGISTERED;

    // No setter and getter... Now used to do cascading
    @OneToMany(cascade = CascadeType.ALL)
    private List<Record> records;

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public Date getDob() {
        return dob;
    }

    public void setDob(Date dob) {
        this.dob = dob;
    }

    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    public String getSsn() {
        return ssn;
    }

    public void setSsn(String ssn) {
        this.ssn = ssn;
    }



public void approve() {
setStatus(Patient.Status.APPROVED);
}


Code:
  public void deny() {
        setStatus(Patient.Status.DENIED);
    }

    public boolean isApproved() {
        return Patient.Status.APPROVED.equals(getStatus());
    }

    public boolean isDenied() {
        return Patient.Status.DENIED.equals(getStatus());
    }

    public Patient.Status getStatus() {
        return status;
    }

    public void setStatus(Patient.Status status) {
        this.status = status;
    }

    public enum Status {
        REGISTERED, APPROVED, DENIED
    }

    public enum Gender {
        MALE, FEMALE
    }
}
[/b][/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 04, 2008 6:33 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

are you sure there is a commit after the method execution? Have you verified this by turning on debug log? Generally a flush() should not be required provided the transaction commits.

--Hardy


Top
 Profile  
 
 Post subject: Does the Transaction Commit
PostPosted: Mon Oct 06, 2008 3:55 am 
Newbie

Joined: Tue Aug 26, 2008 7:01 am
Posts: 12
Location: Zuerich, Switzerland
Hi

The only thing I could figure out was that the weblogic itself shows the transaction as commited. But I guess that Hibernate does somehow not get informed about that commit.... I thought that my configuration is wrong and that I am missing an important point in configuration but couldn't figure it out.

I don't saw anything that hibernate get's information about a commiting transaction. So you'll find the log configuration and the log output below.

Could you give me some hint what to look into?

Log4j.properties:
As far as I understood my hibernate logging should be on debugg. Below my configuration:

Code:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### direct messages to file hibernate.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=C:/bea103/wlserver/samples/domains/medrec/servers/MedRecServer/logs/hibernate.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, stdout, file

#log4j.logger.org.hibernate=info
log4j.logger.org.hibernate=debug

### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug

### log just the SQL
#log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug

### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug

### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug

### log cache activity ###
#log4j.logger.org.hibernate.cache=debug

### log transaction activity
log4j.logger.org.hibernate.transaction=debug

### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace


Log Output of executing PatientRepositoryImpl.approvePatient(...)

As already said the Weblogic Transaction is commited started at the beggining of this slice and commited in the end

09:21:06,400 DEBUG SessionImpl:247 - opened session at timestamp: 12232776664
09:21:06,410 DEBUG JDBCContext:199 - successfully registered Synchronization
09:21:06,420 DEBUG AbstractEntityManagerImpl:439 - Looking for a JTA transaction to join
09:21:06,430 WARN AbstractEntityManagerImpl:543 - Cannot join transaction: do not override hibernate.transaction.factory_class
09:21:06,440 DEBUG Loader:1873 - loading entity: [com.bea.medrec.model.Patient#51]
09:21:06,450 DEBUG AbstractBatcher:410 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
09:21:06,460 DEBUG ConnectionManager:444 - opening JDBC connection
09:21:06,490 DEBUG SQL:111 -
select
patient0_.id as id1_0_,
patient0_.version as version1_0_,
patient0_.email as email1_0_,
patient0_.password as password1_0_,
patient0_.username as username1_0_,
patient0_.firstName as firstName1_0_,
patient0_.lastName as lastName1_0_,
patient0_.middleName as middleName1_0_,
patient0_.phone as phone1_0_,
patient0_.city as city1_0_,
patient0_.country as country1_0_,
patient0_.state as state1_0_,
patient0_.street1 as street13_1_0_,
patient0_.street2 as street14_1_0_,
patient0_.zip as zip1_0_,
patient0_.dob as dob1_0_,
patient0_.gender as gender1_0_,
patient0_.ssn as ssn1_0_,
patient0_.status as status1_0_
from
patients patient0_
where
patient0_.id=?
09:21:06,510 DEBUG AbstractBatcher:426 - about to open ResultSet (open ResultSets: 0, globally: 0)
09:21:06,519 DEBUG Loader:1197 - result row: EntityKey[com.bea.medrec.model.Patient#51]
09:21:06,549 DEBUG AbstractBatcher:433 - about to close ResultSet (open ResultSets: 1, globally: 1)
09:21:06,559 DEBUG AbstractBatcher:418 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
09:21:06,579 DEBUG ConnectionManager:427 - aggressively releasing JDBC connection
09:21:06,589 DEBUG ConnectionManager:464 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
09:21:06,599 DEBUG TwoPhaseLoad:130 - resolving associations for [com.bea.medrec.model.Patient#51]
09:21:06,609 DEBUG TwoPhaseLoad:226 - done materializing entity [com.bea.medrec.model.Patient#51]
09:21:06,619 DEBUG StatefulPersistenceContext:860 - initializing non-lazy collections
09:21:06,629 DEBUG Loader:1904 - done entity load


Top
 Profile  
 
 Post subject: Does the Transaction Commit
PostPosted: Mon Oct 06, 2008 3:57 am 
Newbie

Joined: Tue Aug 26, 2008 7:01 am
Posts: 12
Location: Zuerich, Switzerland
Hi

The only thing I could figure out was that the weblogic itself shows the transaction as commited. But I guess that Hibernate does somehow not get informed about that commit.... I thought that my configuration is wrong and that I am missing an important point in configuration but couldn't figure it out.

I don't saw anything that hibernate get's information about a commiting transaction. So you'll find the log configuration and the log output below.

Could you give me some hint what to look into?

Log4j.properties:
As far as I understood my hibernate logging should be on debugg. Below my configuration:

Code:
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### direct messages to file hibernate.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=C:/bea103/wlserver/samples/domains/medrec/servers/MedRecServer/logs/hibernate.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, stdout, file

#log4j.logger.org.hibernate=info
log4j.logger.org.hibernate=debug

### log HQL query parser activity
#log4j.logger.org.hibernate.hql.ast.AST=debug

### log just the SQL
#log4j.logger.org.hibernate.SQL=debug

### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=info
#log4j.logger.org.hibernate.type=debug

### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug

### log HQL parse trees
#log4j.logger.org.hibernate.hql=debug

### log cache activity ###
#log4j.logger.org.hibernate.cache=debug

### log transaction activity
log4j.logger.org.hibernate.transaction=debug

### log JDBC resource acquisition
#log4j.logger.org.hibernate.jdbc=debug

### enable the following line if you want to track down connection ###
### leakages when using DriverManagerConnectionProvider ###
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace


Log Output of executing PatientRepositoryImpl.approvePatient(...)

As already said the Weblogic Transaction is commited started at the beggining of this slice and commited in the end

09:21:06,400 DEBUG SessionImpl:247 - opened session at timestamp: 12232776664
09:21:06,410 DEBUG JDBCContext:199 - successfully registered Synchronization
09:21:06,420 DEBUG AbstractEntityManagerImpl:439 - Looking for a JTA transaction to join
09:21:06,430 WARN AbstractEntityManagerImpl:543 - Cannot join transaction: do not override hibernate.transaction.factory_class
09:21:06,440 DEBUG Loader:1873 - loading entity: [com.bea.medrec.model.Patient#51]
09:21:06,450 DEBUG AbstractBatcher:410 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
09:21:06,460 DEBUG ConnectionManager:444 - opening JDBC connection
09:21:06,490 DEBUG SQL:111 -
select
patient0_.id as id1_0_,
patient0_.version as version1_0_,
patient0_.email as email1_0_,
patient0_.password as password1_0_,
patient0_.username as username1_0_,
patient0_.firstName as firstName1_0_,
patient0_.lastName as lastName1_0_,
patient0_.middleName as middleName1_0_,
patient0_.phone as phone1_0_,
patient0_.city as city1_0_,
patient0_.country as country1_0_,
patient0_.state as state1_0_,
patient0_.street1 as street13_1_0_,
patient0_.street2 as street14_1_0_,
patient0_.zip as zip1_0_,
patient0_.dob as dob1_0_,
patient0_.gender as gender1_0_,
patient0_.ssn as ssn1_0_,
patient0_.status as status1_0_
from
patients patient0_
where
patient0_.id=?
09:21:06,510 DEBUG AbstractBatcher:426 - about to open ResultSet (open ResultSets: 0, globally: 0)
09:21:06,519 DEBUG Loader:1197 - result row: EntityKey[com.bea.medrec.model.Patient#51]
09:21:06,549 DEBUG AbstractBatcher:433 - about to close ResultSet (open ResultSets: 1, globally: 1)
09:21:06,559 DEBUG AbstractBatcher:418 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
09:21:06,579 DEBUG ConnectionManager:427 - aggressively releasing JDBC connection
09:21:06,589 DEBUG ConnectionManager:464 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
09:21:06,599 DEBUG TwoPhaseLoad:130 - resolving associations for [com.bea.medrec.model.Patient#51]
09:21:06,609 DEBUG TwoPhaseLoad:226 - done materializing entity [com.bea.medrec.model.Patient#51]
09:21:06,619 DEBUG StatefulPersistenceContext:860 - initializing non-lazy collections
09:21:06,629 DEBUG Loader:1904 - done entity load


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2008 11:43 am 
Newbie

Joined: Tue Aug 26, 2008 7:01 am
Posts: 12
Location: Zuerich, Switzerland
Now I could figure out the error. It was really in configuration.
I declared the CMTTransaction stuff what I shouldn't have done.

Anyway thanks a lot for the hint about the transaction enlistment. It got me on track to debug at the right places and then figure it out with the documenation.

Now the correct configuration for Weblogic 10.3 / Hibernate 3.4 GA with JPA / CMT is as followed:

Code:
    <persistence-unit name="MedRec" transaction-type="JTA">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>jdbc/MedRecGlobalDataSourceXA</jta-data-source>
        <class>com.bea.medrec.model.Address</class>
        <class>com.bea.medrec.model.Administrator</class>
        <class>com.bea.medrec.model.BaseEntity</class>
        <class>com.bea.medrec.model.PersonName</class>
        <class>com.bea.medrec.model.Patient</class>
        <class>com.bea.medrec.model.Physician</class>
        <class>com.bea.medrec.model.Prescription</class>
        <class>com.bea.medrec.model.Record</class>
        <class>com.bea.medrec.model.RegularUser</class>
        <class>com.bea.medrec.model.User</class>
        <class>com.bea.medrec.model.VersionedEntity</class>
        <class>com.bea.medrec.model.VitalSigns</class>
        <properties>
            <!-- SQL stdout logging -->
             <property name="hibernate.show_sql" value="true"/>
             <property name="hibernate.format_sql" value="true"/>
             <property name="use_sql_comments" value="true"/>
             
             <!-- to prevent the ClassDefNotFound problem with weblogic -->
         <property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/>

             <property name="hibernate.c3p0.min_size" value="5"/>
             <property name="hibernate.c3p0.max_size" value="20"/>
             <property name="hibernate.c3p0.timeout" value="300"/>
             <property name="hibernate.c3p0.max_statements" value="50"/>
           <property name="hibernate.c3p0.idle_test_period" value="3000"/>

         <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>
             <property name="hibernate.dialect" value="org.hibernate.dialect.PointbaseDialect"/>
        </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.  [ 6 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.