klayton wrote:
I am trying to use hibernate with MS Sql Server 2000, and I am using the JTDS driving recommended on the Hibernate Documentation.
I have having trouble to insert row to the database, here is the relative xml parts in the mapping.xml and hibernate.cfg
when i do an insert it gives me:
java.sql.SQLException: Was expecting a result set
at net.sourceforge.jtds.jdbc.PreparedStatement_base.executeQuery(PreparedStatement_base.java:260)
at com.mchange.v2.c3p0.impl.C3P0PreparedStatement.executeQuery(C3P0PreparedStatement.java:188)
at com.mchange.v2.c3p0.impl.C3P0PooledConnection$2.executeQuery(C3P0PooledConnection.java:473)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:508)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:906)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:839)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:757)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:720)
p.s. where can i find documentation on the proper way to set up with SQL Server...?
You need to set:
hibernate.jdbc.use_get_generated_keys true
in your hibernate.properties. select @@identity does not seemk to work with jTDS.
Gary Evesson