net.sf.hibernate.JDBCException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • When experimenting with defining id's and using the 'identity' generator I noticed that the sybase mapping is broken if the class only has an id column. When saving such a class the SQL: insert into ABusinessObject DEFAULT VALUES is produced. I think that this should be : insert into ABusinessObject values ( ) The fix would be to delete the method getNoColumnsInsertString in the class net.sf.hibernate.dialect.SybaseDialect. This overrides the method in net.sf.hibernate.dialect.Dialect which looks to me like it (Dialect) produces the correct SQL. This is an usual case - I don't think it would be likely that I will need to persist a class that only has an id/identity. The SQL is fine if there is at least one property defined for the class. Below is I hope enough details to reproduce the (minor) problem. Consider the following mapping <hibernate-mapping> <class name="test.ABusinessObject" table="ABusinessObject"> <id name="id" type="integer" unsaved-value="null"> <column name="id" sql-type="numeric(10,0)"/> <generator class="identity"/> </id> </class> </hibernate-mapping> The test.ABusinessObject class: public class ABusinessObject { private Integer id; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } } In my test code I have: Session session = // ... open session ABusinessObject aBusinessObject = new ABusinessObject(); session.save(aBusinessObject); At the point of save with the above mapping the log shows (I have log priority set to debug, and flagged to echo sql is on): Hibernate: insert into ABusinessObject DEFAULT VALUES 09:35:09,622 WARN JDBCExceptionReporter:38 - SQL Error: 156, SQLState: ZZZZZ 09:35:09,632 ERROR JDBCExceptionReporter:46 - Incorrect syntax near the keyword 'DEFAULT'. and the following exception occurs: net.sf.hibernate.JDBCException: could not insert: [test.ABusinessObject] at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:541) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:433) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:876) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:737) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717) at test.TestABusinessObject.testABusinessObject(TestABusinessObject.java:29)
    via by Grainne Coghlan,
  • When experimenting with defining id's and using the 'identity' generator I noticed that the sybase mapping is broken if the class only has an id column. When saving such a class the SQL: insert into ABusinessObject DEFAULT VALUES is produced. I think that this should be : insert into ABusinessObject values ( ) The fix would be to delete the method getNoColumnsInsertString in the class net.sf.hibernate.dialect.SybaseDialect. This overrides the method in net.sf.hibernate.dialect.Dialect which looks to me like it (Dialect) produces the correct SQL. This is an usual case - I don't think it would be likely that I will need to persist a class that only has an id/identity. The SQL is fine if there is at least one property defined for the class. Below is I hope enough details to reproduce the (minor) problem. Consider the following mapping <hibernate-mapping> <class name="test.ABusinessObject" table="ABusinessObject"> <id name="id" type="integer" unsaved-value="null"> <column name="id" sql-type="numeric(10,0)"/> <generator class="identity"/> </id> </class> </hibernate-mapping> The test.ABusinessObject class: public class ABusinessObject { private Integer id; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } } In my test code I have: Session session = // ... open session ABusinessObject aBusinessObject = new ABusinessObject(); session.save(aBusinessObject); At the point of save with the above mapping the log shows (I have log priority set to debug, and flagged to echo sql is on): Hibernate: insert into ABusinessObject DEFAULT VALUES 09:35:09,622 WARN JDBCExceptionReporter:38 - SQL Error: 156, SQLState: ZZZZZ 09:35:09,632 ERROR JDBCExceptionReporter:46 - Incorrect syntax near the keyword 'DEFAULT'. and the following exception occurs: net.sf.hibernate.JDBCException: could not insert: [test.ABusinessObject] at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:541) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:433) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:876) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:737) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717) at test.TestABusinessObject.testABusinessObject(TestABusinessObject.java:29)
    via by Grainne Coghlan,
  • oracle - hibernate
    via wsabi4axis by nobody
    ,
    • net.sf.hibernate.JDBCException: could not insert: [test.ABusinessObject] at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:541) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:433) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:876) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:737) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717) at test.TestABusinessObject.testABusinessObject(TestABusinessObject.java:29)
    No Bugmate found.