hi,
im very new to hibernate. ive been following the tutorial on the site but have come accross a problem when trying to run a simple session.
ive copied the code but ran into a problem with the log.
this is the original code
Code:
private static Log log = LogFactory.getLog(HibernateUtil.class);
im given the options of:
LogFactory (org.apache.commons.logging)
Log4jFactory(org.apache.commons.logging.impl
i changed it to:
Log4jFactory(org.apache.commons.logging.impl
then im asked for the Log to change to:
Log (org.apache.commons.logging
Logger (org.apache.log4j)
LogLog (org.apache.log4j.helper)
i changed it to:
Logger (org.apache.log4j)
the line ends up being:
rivate static Logger log = (Logger) Log4jFactory.getLog(HibernateUtil.class);
instead of:
private static Log log = LogFactory.getLog(HibernateUtil.class);
this is my main class
Code:
package net.sf.hibernate.examples.quickstart;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
public class TestHibernate
{
public static void main(String args[]) throws HibernateException
{
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
Cat tom = new Cat();
tom.setName("tom");
tom.setSex('F');
tom.setWeight(7.4f);
session.save(tom);
tx.commit();
HibernateUtil.closeSession();
}
}
the error occurs at:
Session session = HibernateUtil.currentSession();
my error is this:
Code:
java.lang.ExceptionInInitializerError
at net.sf.hibernate.examples.quickstart.TestHibernate.main(TestHibernate.java:12)
Caused by: java.lang.ClassCastException
at net.sf.hibernate.examples.quickstart.HibernateUtil.<clinit>(HibernateUtil.java:11)
... 1 more
Exception in thread "main"
can anyone see what im doing wrong
thanks for the help