Hibernate version:2.1
JDK version:1.4.2_05
[b]Name and version of the database you are using:
Database Oracle 9i: JDBC 10G thin driver come with BEA 8.1 sp4
Short description of problem:
We use Hibernate inside BEA weblogic 8.1sp4 server try to import data of a master/detail structure record. lets said HeaderRecord/DetailRecord respectively. every time when we do the insert we first delete the old recod and then do the insert. this sound very simple process but it crash the whole BEA JVM when this process is running against 50 HeaderRecord with 1700 DetailRecord. Server is quite when we do the import.
We have ton of memory on this machine we assign 1G to JVM.
We work through BEA support team, we didn't get enough support from them because they think it is Hibernate native code cause this crash.
We painfully migrate the Hibernate to pure JDBC code it is now running on our production for more than three weeks without crash.
We are 99% sure at this moment the crash is related to Hibernate, we would like to ask someone here experience the same problem and could help us out.
Hibernate configure
Code:
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- properties -->
<property name="connection.datasource">DBConnection</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">false</property>
<property name="use_outer_join">false</property>
<property name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.Provider</property>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="jndi.class">weblogic.jndi.WLInitialContextFactory</property>
<property name="jndi.url">t3://virtual-app:9001</property>
<!-- mapping files -->
<mapping resource="com/onlane/inspection/vis/DetailRecord.hbm.xml"/>
<mapping resource="com/onlane/inspection/vis/HeaderRecord.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Mapping documents:<mapping resource="com/onlane/inspection/vis/HeaderRecord.hbm.xml"/>
Code:
<hibernate-mapping>
<class
name="com.onlane.inspection.vis.HeaderRecord"
table="ONL_STAGING_VIS_VEHICLE"
>
<id
name="refID"
column="REFID"
type="java.lang.String"
length="15"
>
<generator class="assigned">
</generator>
</id>
<property
name="recordType"
type="string"
update="false"
insert="false"
column="RECTYPE"
length="1"
/>
<property
name="inspID"
type="string"
update="true"
insert="true"
column="INSPID"
length="10"
/>
<property
name="status"
type="string"
update="true"
insert="true"
column="STATUSCODE"
length="1"
/>
<property
name="reason"
type="string"
update="true"
insert="true"
column="REASONCODE"
length="2"
/>
<property
name="apptDate"
type="date"
update="true"
insert="true"
column="APPTDATE"
length="10"
/>
<property
name="contactLastname"
type="string"
update="true"
insert="true"
column="LASTNAME"
length="40"
/>
<property
name="contactFirstname"
type="string"
update="true"
insert="true"
column="FIRSTNAME"
length="20"
/>
<property
name="contactInitial"
type="string"
update="true"
insert="true"
column="MIDDLEINIT"
length="1"
/>
<property
name="contactAddr1"
type="string"
update="true"
insert="true"
column="ADDR1"
length="35"
/>
<property
name="contactAddr2"
type="string"
update="true"
insert="true"
column="ADDR2"
length="35"
/>
<property
name="contactCity"
type="string"
update="true"
insert="true"
column="CITY"
length="30"
/>
<property
name="contactState"
type="string"
update="true"
insert="true"
column="STATECODE"
length="2"
/>
<property
name="contactZip"
type="string"
update="true"
insert="true"
column="ZIPCODE"
length="5"
/>
<property
name="contactZipExt"
type="string"
update="true"
insert="true"
column="ZIPCODEPLUS"
length="4"
/>
<property
name="contactPostalCode"
type="string"
update="true"
insert="true"
column="POSTALCODE"
length="6"
/>
<property
name="contactCountry"
type="string"
update="true"
insert="true"
column="COUNTRYCODE"
length="3"
/>
<property
name="custLastname"
type="string"
update="true"
insert="true"
column="CUSTLASTNAME"
length="40"
/>
<property
name="custFirstname"
type="string"
update="true"
insert="true"
column="CUSTFIRSTNAME"
length="20"
/>
<property
name="custInitial"
type="string"
update="true"
insert="true"
column="CUSTMIDDLEINIT"
length="1"
/>
<property
name="VIN"
type="string"
update="true"
insert="true"
column="VIN"
length="17"
/>
<property
name="year"
type="java.lang.Short"
update="true"
insert="true"
column="YEAR"
length="4"
/>
<property
name="make"
type="string"
update="true"
insert="true"
column="MAKE"
length="25"
/>
<property
name="model"
type="string"
update="true"
insert="true"
column="MODEL"
length="25"
/>
<property
name="license"
type="string"
update="true"
insert="true"
column="VEHLICENSE"
length="8"
/>
<property
name="stateCode"
type="string"
update="true"
insert="true"
column="VEHSTATECODE"
length="2"
/>
<property
name="odometer"
type="string"
update="true"
insert="true"
column="ODOMETER"
length="10"
/>
<property
name="testDrive"
type="string"
update="true"
insert="true"
column="TESTDRIVEN"
length="1"
/>
<property
name="diagNeeded"
type="string"
update="true"
insert="true"
column="DIAGREQUIRED"
length="1"
/>
<property
name="engineSize"
type="string"
update="true"
insert="true"
column="ENGINESIZE"
length="20"
/>
<property
name="trim"
type="string"
update="true"
insert="true"
column="BODYTYPE"
length="20"
/>
<property
name="transmission"
type="string"
update="true"
insert="true"
column="TRANSMISSION"
length="20"
/>
<property
name="inspDate"
type="date"
update="true"
insert="true"
column="INSPDATE"
length="10"
/>
<property
name="seriesName"
type="string"
update="true"
insert="true"
column="SERIESNAME"
length="15"
/>
<property
name="extColour"
type="string"
update="true"
insert="true"
column="EXTCOLOUR"
length="12"
/>
<property
name="driveDesc"
type="string"
update="true"
insert="true"
column="DRIVEDESC"
length="20"
/>
<property
name="intColour"
type="string"
update="true"
insert="true"
column="INTCOLOUR"
length="12"
/>
</class>
</hibernate-mapping>
<mapping resource="com/onlane/inspection/vis/DetailRecord.hbm.xml"/>
Code:
<hibernate-mapping>
<class
name="com.onlane.inspection.vis.DetailRecord"
table="ONL_STAGING_VIS_DETAIL"
>
<id
name="recID"
column="RECID"
type="java.lang.String"
length="32"
>
<generator class="uuid.hex">
</generator>
</id>
<property
name="refID"
type="java.lang.String"
update="true"
insert="true"
column="REFID"
length="15"
/>
<property
name="recordType"
type="string"
update="false"
insert="false"
column="RECTYPE"
length="1"
/>
<property
name="area"
type="string"
update="true"
insert="true"
column="AREA"
length="25"
/>
<property
name="part"
type="string"
update="true"
insert="true"
column="part"
length="25"
/>
<property
name="description"
type="string"
update="true"
insert="true"
column="description"
length="25"
/>
<property
name="repair"
type="string"
update="true"
insert="true"
column="repair"
length="1"
/>
<property
name="replace"
type="string"
update="true"
insert="true"
column="replace"
length="1"
/>
<property
name="refinish"
type="string"
update="true"
insert="true"
column="refinish"
length="1"
/>
<property
name="metalHrs"
type="java.math.BigDecimal"
update="true"
insert="true"
column="metalHrs"
length="5"
/>
<property
name="paintHrs"
type="java.math.BigDecimal"
update="true"
insert="true"
column="paintHrs"
length="5"
/>
<property
name="generalHrs"
type="java.math.BigDecimal"
update="true"
insert="true"
column="generalHrs"
length="5"
/>
<property
name="labourCost"
type="java.math.BigDecimal"
update="true"
insert="true"
column="labourCost"
length="10"
/>
<property
name="partsCost"
type="java.math.BigDecimal"
update="true"
insert="true"
column="partsCost"
length="10"
/>
<property
name="wearAndTear"
type="java.math.BigDecimal"
update="true"
insert="true"
column="wearAndTear"
length="10"
/>
<property
name="flag"
type="string"
update="true"
insert="true"
column="flag"
length="1"
/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
public class HibernateUtil {
private static Configuration config = null;
private static SessionFactory sessionFactory=null;
private static Logger _log = LogFactory.getInstance(HibernateUtil.class);
static {
try {
// Create the SessionFactory
config = new Configuration().configure();
sessionFactory = config.buildSessionFactory();
} catch (HibernateException ex) {
LogFactory.getInstance(HibernateUtil.class).error("Configuration problem: " + ex.getMessage(), ex);
}
System.err.println( "HibernateUtil: static initializer: session factory = '" +
sessionFactory + "'" );
}
public static final ThreadLocal session = new ThreadLocal();
public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null || !s.isOpen()) {
if( sessionFactory == null )
throw( new HibernateException( "HibernateUtil: currentSession: sessionFactory is null" ) );
s = sessionFactory.openSession();
session.set(s);
}
else if(!s.isConnected()){
s.reconnect();
}
return s;
}
public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null){
s.close();
}
}
public static PersistentClass getPersistentClass( Class clazz ) {
if( config == null )
return( null );
return( config.getClassMapping( clazz ) );
}
}
My Hibernate client codeCode:
Session session = null;
Transaction transaction = null;
try {
session = HibernateUtil.currentSession();
transaction = session.beginTransaction();
//my code start here
...
//my code end here
transaction.commit();
} catch (HibernateException e) {
try{ if (transaction != null) transaction.rollback();} catch (HibernateException ex){}
_log.error("", e);
}finally{
try {HibernateUtil.closeSession();} catch (HibernateException e1) {}
}