I'm using Weblogic Server 8.1 and I looked in the log and I only get the normal DEBUG messages from Hibernate. I can post them to see if they help but I don't think it's likely. I'm also going to post my classes and methods so you can take a look and see:
Code:
public class TVMHibernateUtil {
private static Logger logger = Logger.getLogger("TVMHibernateUtil");
// Used for log messages (DEBUGGING)
private String CLASS_NAME = "tellarian.valuation.valuator.session.TVMHibernateUtil";
// For Connection
private static String file = "/hibernate.cfg.xml";
//Get a SessionFactory
private static final SessionFactory sessionFactory;
static {
try {
// Create the SessionFactory
URL url = TVMHibernateUtil.class.getResource(file);
sessionFactory = new Configuration().configure(url).buildSessionFactory();
} catch (Throwable ex) {
logger.error("Initial SessionFactory creation failed.", ex);
throw new ExceptionInInitializerError(ex);
}
}
/**
* <p>
* Sets the associated session context. The container calls this method after the instance creation.
* </p>
*/
public static Session openSession() throws HibernateException{
try {
Session session;
session = sessionFactory.openSession();
return session;
} catch (HibernateException e) {
logger.debug("Error while opening hibernate session: " + e);
throw e;
}
}
public static void closeSession(Session session) throws HibernateException{
try {
if(!session.isOpen()){
session.close();
}
} catch (HibernateException e) {
logger.debug("Error while closing hibernate session: " + e);
throw e;
}
}
}
Code:
public class TVMHibernateManager {
private static Logger logger = Logger.getLogger("TVMHibernateManager");
private static String CLASS_NAME = "TVMHibernateManager";
/**
* Persist a record to the database
*/
public void saveRecord(HibernateConsumptionRecord record){
try {
Session session = TVMHibernateUtil.openSession();
session.save(record);
session.flush();
TVMHibernateUtil.closeSession(session);
} catch (Exception e){
e.printStackTrace();
}
}
/**
* Find all records that correspond to this user Id
*/
public List getRecordsByUserId(String userId) throws TellarianException{
String methodName = "getRecordsByUserId";
try {
Session session = TVMHibernateUtil.openSession();
List records = session.find(
"from HibernateConsumptionRecord as record where record.userId = ?",
userId,
Hibernate.STRING
);
TVMHibernateUtil.closeSession(session);
return records;
} catch (HibernateException e){
logger.error(e);
throw new TellarianException(CLASS_NAME, methodName,
"Could not find hibernate records by User Id: " + userId);
}
}
/**
* Find all records that correspond to this user Id and were made
* between the given dates.
*/
public List getRecordsByUserIdAndDates(String userId,
Date startDate, Date endDate) throws TellarianException{
String methodName = "getRecordsByUserIdAndDates";
try {
Session session = TVMHibernateUtil.openSession();
List records = session.find(
"from HibernateConsumptionRecord as record where record.userId = ?"
+ " and record.consumptionDate >= ? and record.consumptionDate <= ?",
new Object[] { userId, startDate, endDate},
new Type[] { Hibernate.STRING, Hibernate.DATE, Hibernate.DATE }
);
TVMHibernateUtil.closeSession(session);
return records;
} catch (HibernateException e){
SimpleDateFormat dateFormat = new SimpleDateFormat();
logger.error(e);
throw new TellarianException(CLASS_NAME, methodName,
"Could not find hibernate records by User Id: " + userId
+ " between dates: " + dateFormat.format(startDate) + " and "
+ dateFormat.format(endDate));
}
}
/**
* Find all records that correspond to this cost center
*/
public List getRecordsByCostCenter(String costCenterId) throws TellarianException{
String methodName = "getRecordsByCostCenter";
try {
Session session = TVMHibernateUtil.openSession();
List records = session.find(
"from HibernateConsumptionRecord as record where record.costCenterId = ?",
costCenterId,
Hibernate.STRING
);
TVMHibernateUtil.closeSession(session);
return records;
} catch (HibernateException e){
logger.error(e);
throw new TellarianException(CLASS_NAME, methodName,
"Could not find hibernate records by Cost Center: " + costCenterId);
}
}
/**
* Find all records that correspond to this cost center and were made
* between the given dates.
*/
public List getRecordsByCostCenterAndDates(String costCenterId,
Date startDate, Date endDate) throws TellarianException {
String methodName = "getRecordsByCostCenterAndDates";
try {
Session session = TVMHibernateUtil.openSession();
List records = session.find(
"from HibernateConsumptionRecord as record where record.costCenterId = ?"
+ " and record.consumptionDate >= ? and record.consumptionDate <= ?",
new Object[] { costCenterId, startDate, endDate},
new Type[] { Hibernate.STRING, Hibernate.DATE, Hibernate.DATE }
);
TVMHibernateUtil.closeSession(session);
return records;
} catch (HibernateException e){
SimpleDateFormat dateFormat = new SimpleDateFormat();
logger.error(e);
throw new TellarianException(CLASS_NAME, methodName,
"Could not find hibernate records by Cost Center: " + costCenterId
+ " between dates: " + dateFormat.format(startDate) + " and "
+ dateFormat.format(endDate));
}
}
}
Here is the log:
DEBUG [13:04:57] (BatcherImpl.java:getPreparedStatement:253) - preparing statement
DEBUG [13:04:57] (NullableType.java:nullSafeSet:46) - binding '262' to parameter: 1
DEBUG [13:04:57] (NullableType.java:nullSafeSet:46) - binding '01 March 2005' to parameter: 2
DEBUG [13:04:57] (NullableType.java:nullSafeSet:46) - binding '01 April 2005' to parameter: 3
DEBUG [13:04:57] (Loader.java:doQuery:281) - processing result set
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '12' as column: id
DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 12
DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 12
DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#12
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 00:22:41' as column: consumpt4_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596004946' as column: dialedNu5_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '721' as column: duration
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '72.1' as column: cost
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '13' as column: id
DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 13
DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 13
DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#13
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 00:23:16' as column: consumpt4_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596004946' as column: dialedNu5_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '721' as column: duration
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '72.1' as column: cost
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
DEBUG [13:04:57] (SessionImpl.java:finalize:3435) - running Session.finalize()
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '205' as column: id
DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 205
DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 205
DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#205
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 17:12:15' as column: consumpt4_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80992311203' as column: dialedNu5_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '12' as column: duration
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '0.24' as column: cost
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '223' as column: id
DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 223
DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 223
DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#223
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 17:39:23' as column: consumpt4_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596004946' as column: dialedNu5_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: duration
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '0.1' as column: cost
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '231' as column: id
DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 231
DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 231
DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#231
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 17:35:39' as column: consumpt4_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596004946' as column: dialedNu5_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: duration
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '0.1' as column: cost
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '239' as column: id
DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 239
DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 239
DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#239
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-17 17:40:17' as column: consumpt4_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596004946' as column: dialedNu5_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: duration
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '0.1' as column: cost
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '551' as column: id
DEBUG [13:04:57] (Loader.java:getRow:484) - result row: 551
DEBUG [13:04:57] (Loader.java:loadFromResultSet:615) - Initializing object from ResultSet: 551
DEBUG [13:04:57] (Loader.java:hydrate:684) - Hydrating entity: com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#551
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '635684' as column: extension
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: pbxId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '2005-03-18 10:12:32' as column: consumpt4_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning 'A80596943031' as column: dialedNu5_
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '1' as column: duration
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '0.1' as column: cost
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '262' as column: userId
DEBUG [13:04:57] (NullableType.java:nullSafeGet:68) - returning '110' as column: costCent9_
DEBUG [13:04:57] (Loader.java:doQuery:298) - done processing result set (7 rows)
DEBUG [13:04:57] (BatcherImpl.java:logClosePreparedStatement:211) - done closing: 0 open PreparedStatements, 0 open ResultSets
DEBUG [13:04:57] (BatcherImpl.java:closePreparedStatement:275) - closing statement
DEBUG [13:04:57] (Loader.java:initializeEntitiesAndCollections:318) - total objects hydrated: 7
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#12]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#12]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#13]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#13]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#205]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#205]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#223]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#223]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#231]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#231]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#239]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#239]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2216) - resolving associations for [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#551]
DEBUG [13:04:57] (SessionImpl.java:initializeEntity:2247) - done materializing entity [com.acmgrp.tellarian.valuation.record.HibernateConsumptionRecord#551]
DEBUG [13:04:57] (SessionImpl.java:initializeNonLazyCollections:3161) - initializing non-lazy collections
DEBUG [13:04:57] (SessionImpl.java:close:578) - closing session
DEBUG [13:04:57] (SessionImpl.java:disconnect:3383) - disconnecting session
DEBUG [13:04:57] (SessionImpl.java:afterTransactionCompletion:596) - transaction completion
Hope this helps. Thanks.