This is the code snippit from a class called ConnectionFactory:
Code:
private static void buildSessionFactory()
{
try
{
Configuration hibernateConfig = new Configuration();
try
{
hibernateConfig.configure();
}
catch (HibernateException ex)
{
ResourceBundle bundle = PropertyResourceBundle.getBundle("J2EE");
hibernateConfig.addFile((String)bundle.getObject("sobetech.hibernate.config")
+ "/" + configFileName);
}
factory = hibernateConfig.buildSessionFactory();
}
catch (HibernateException ex)
{
factory = null;
}
}
public static Session getSession() throws HibernateException
{
if(factory == null)
{
buildSessionFactory();
}
return factory.openSession();
}
So when I want a session I call:
Code:
Session session = ConnectionFactory.getSession();
I get the session Object
This is an offending method that is causing my errors:
Code:
public Cart updateCart(Cart cart) throws EAOException
{
try
{
session = ConnectionFactory.getSession();
session.update(cart);
session.flush();
session.close();
session = null;
return cart;
}
catch (HibernateException ex)
{
throw new EAOException(ex);
}
}
These are the settings that I have in the hibernate.cfg.xml:
Code:
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.query.substitutions">true 'T', false 'F', yes 'Y', no 'N'</property>
<property name="hibernate.connection.datasource">sobetech.jdbc.datasource.smoke</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.transaction.manager_lookup_class">net.sf.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.jdbc.batch_size">0</property>
<property name="hibernate.jdbc.use_streams_for_binary">true</property>
<property name="hibernate.jndi.url">t3://localhost:7001</property>
<property name="hibernate.jndi.class">weblogic.jndi.WLInitialContextFactory</property>
<property name="hibernate.max_fetch_depth">1</property>
<property name="hibernate.cache.region_prefix">hibernate.test</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.provider_class">net.sf.ehcache.hibernate.Provider</property>
<property name="hibernate.dialect">net.sf.hibernate.dialect.OracleDialect</property>
[i]mappings....[/i]
</session-factory>
</hibernate-configuration>