- This topic has 1 reply, 2 voices, and was last updated 16 years, 7 months ago by Loyal Water.
-
AuthorPosts
-
kirankarreMemberhi Guys,
I am using MSAccess as DB, and i have written a Dialect for that. And when i was trying to insert/update the record i am getting the following error.org.hibernate.exception.GenericJDBCException: could not insert: [com.Honey]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2078)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2427)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.Test.createHoney(Test.java:90)
at com.Test.main(Test.java:25)This is CFG file
<session-factory><property name=”hibernate.connection.driver_class”>
sun.jdbc.odbc.JdbcOdbcDriver
</property>
<property name=”hibernate.connection.password”></property>
<property name=”hibernate.connection.url”>
jdbc:odbc:test
</property>
<property name=”hibernate.connection.username”></property>
<property name=”hibernate.dialect”>
com.MSAccessDialect
</property><property name=”hbm2ddl.auto”>update</property>
<property name=”show_sql”>true</property><mapping resource=”Honey.hbm.xml” />
</session-factory>This is my dialect clss
public class MSAccessDialect extends Dialect {
public MSAccessDialect() {
super();
registerColumnType(Types.BIT, “BIT”);
registerColumnType(Types.BIGINT, “INTEGER”);
registerColumnType(Types.SMALLINT, “SMALLINT”);
registerColumnType(Types.TINYINT, “BYTE”);
registerColumnType(Types.INTEGER, “INTEGER”);
registerColumnType(Types.CHAR, “VARCHAR(1)”);
registerColumnType(Types.VARCHAR, “VARCHAR($l)”);
registerColumnType(Types.FLOAT, “DOUBLE”);
registerColumnType(Types.DOUBLE, “DOUBLE”);
registerColumnType(Types.DATE, “DATETIME”);
registerColumnType(Types.TIME, “DATETIME”);
registerColumnType(Types.TIMESTAMP, “DATETIME”);
registerColumnType(Types.VARBINARY, “VARBINARY($l)”);
registerColumnType(Types.NUMERIC, “NUMERIC”);getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE,
“0”);
}public String getIdentityColumnString() {
return “AutoNumber NOT NULL”;
}public String getIdentitySelectString() {
return “select @@IDENTITY”;
}This is my Test class code
private static void create(Honey honey) {
Transaction tx = null;
// Session session =
// InitSessionFactory.getInstance().getCurrentSession();
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
System.err.println(“insert”);
try {
tx = session.beginTransaction();
tx.begin();
session.save(honey);
tx.commit();
} catch (HibernateException e) {
e.printStackTrace();
}finally{
sessionFactory.close();
// Actual contact insertion will happen at this step
session.flush();
session.close();}
}
Loyal WaterMemberMoving to Off Topic >> Software Development
-
AuthorPosts