Hi,
new to Hibernate. just started exploring. iam having the problems with my first example.
Version: Hibernate 3
Database: Oracle 10g
Emp.cfg.xml:
<class name="Emp" table="EMP">
<meta attribute="sync-DAO">false</meta>
<id name="empno" type="int" column="EMPNO">
<generator class="native">
</generator>
</id>
application code:
Session session = HibernateHelper.getSessionFactory()
.getCurrentSession();
session.beginTransaction();
Emp emp = new Emp();
emp.setEname("A");
emp.setJob("Manager");
emp.setMgr(1000);
emp.setHiredate(new java.util.Date());
emp.setSal(12345.67);
emp.setComm(123.45);
emp.setDeptno(10);
// emp.setEmpno(1000);
session.save(emp);
session.getTransaction().commit();
iam getting the following exception.
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select hibernate_sequence.nextval from dual
Exception in thread "main" java.lang.ClassCastException: java.lang.Integer
at org.hibernate.type.StringType.toString(StringType.java:44)
at org.hibernate.type.NullableType.toLoggableString(NullableType.java:218)
at org.hibernate.pretty.Printer.toString(Printer.java:53)
at org.hibernate.pretty.Printer.toString(Printer.java:90)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:97)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at events.Main.createAndStoreEmployee(Main.java:32)
at events.Main.main(Main.java:9)
Can someone help on this?
Thanks,
Raj
|