I am trying to write first project from hibernate.org documentation on EVENTS table. I am experiencing some issues with updating the database.
My EventManager which creates and stores the Event is like this:
Code:
private void createAndStoreEvent(String title, Date theDate) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);
session.save(theEvent);
session.getTransaction().commit();
}
My Hibernate configuration is like this:
Code:
<session-factory>
<property name="hibernate.connection.driver_class">sun.jdbc.odbc.JdbcOdbcDriver</property>
<property name="hibernate.connection.url">jdbc:odbc:ds1</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">***</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<property name="hibernate.show_sql">true</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping resource="hibernate.hbm.xml"/>
</session-factory>
Hibernate Mapping XML is like this:
Code:
<hibernate-mapping package="com.home.mavenproject1">
<class name="Event" table="EVENTS" schema="SCOTT">
<id name="id" column="EVENT_ID">
<generator class="sequence">
<param name="sequence">EVENTS_SEQ</param>
</generator>
</id>
<property name="date" type="date" column="EVENT_DATE"/>
<property name="title" type="string" column="TITLE"/>
</class>
</hibernate-mapping>
Also, finally table is like this in DB:
Code:
SQL> desc events;
Name Null? Type
----------------------------------------- -------- ----------------------------
EVENT_ID NOT NULL NUMBER(19)
EVENT_DATE DATE
TITLE VARCHAR2(255)
SQL>
I am getting the following exception. Can you please suggest a solution to rectify this error?
Code:
INFO: schema export complete
Hibernate: select EVENTS_SEQ.nextval from dual
Hibernate: insert into SCOTT.EVENTS (EVENT_DATE, TITLE, EVENT_ID) values (?, ?, ?)
Oct 1, 2011 5:24:00 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: S1000
Oct 1, 2011 5:24:00 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: General error
Oct 1, 2011 5:24:00 PM org.hibernate.event.def.AbstractFlushingEventListener performExecutions
SEVERE: Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at com.home.mavenproject1.Manager.EventManager.createAndStoreEvent(EventManager.java:42)
at com.home.mavenproject1.Manager.EventManager.main(EventManager.java:24)
Caused by: sun.jdbc.odbc.JdbcOdbcBatchUpdateException: General error
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.emulateExecuteBatch(JdbcOdbcPreparedStatement.java:2165)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeBatchUpdate(JdbcOdbcPreparedStatement.java:1783)
at sun.jdbc.odbc.JdbcOdbcStatement.executeBatch(JdbcOdbcStatement.java:912)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 9 more
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
at com.home.mavenproject1.Manager.EventManager.createAndStoreEvent(EventManager.java:42)
at com.home.mavenproject1.Manager.EventManager.main(EventManager.java:24)
Caused by: sun.jdbc.odbc.JdbcOdbcBatchUpdateException: General error
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.emulateExecuteBatch(JdbcOdbcPreparedStatement.java:2165)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeBatchUpdate(JdbcOdbcPreparedStatement.java:1783)
at sun.jdbc.odbc.JdbcOdbcStatement.executeBatch(JdbcOdbcStatement.java:912)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 9 more
Oct 1, 2011 5:24:01 PM org.hibernate.impl.SessionFactoryImpl close
INFO: closing
Oct 1, 2011 5:24:01 PM org.hibernate.connection.DriverManagerConnectionProvider close
INFO: cleaning up connection pool: jdbc:odbc:ds1