-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Empty SQL statements with Hibernate 3.1beta3 and 3.1beta2
PostPosted: Wed Sep 21, 2005 11:55 am 
Beginner
Beginner

Joined: Wed Apr 13, 2005 10:34 am
Posts: 38
I'm running into problems using 3.1beta3 as a drop-in replacement of 3.0.5. All CRUD SQL statements seem to be empty. The funny thing is, JDBCExceptionReporter prints the correct statements, while SQL.log prints an empty line.

Creating Configuration and SessionFactory looks ok, no warnings or errors are logged. SchemaExport/Update runs fine too.

I tried replacing 3.1beta3 with 3.1beta2 and got the same error.
Then i tried 3.1beta1 and it just works as 3.0.5 did.

I'm a little clueless right now. Anybody else has this problem?

Here's a log excerpt with the exception stacktrace:
Code:
2005-09-21 17:12:35,398 [main] DEBUG SessionImpl.<init>():270 - opened session at timestamp: 4617484514463744
2005-09-21 17:12:35,414 [main] DEBUG VersionValue.isUnsaved():44 - version unsaved-value strategy UNDEFINED
2005-09-21 17:12:35,414 [main] DEBUG AbstractSaveEventListener.getEntityState():461 - transient instance of: com.company.model.Test
2005-09-21 17:12:35,414 [main] DEBUG DefaultSaveOrUpdateEventListener.entityIsTransient():161 - saving transient instance
2005-09-21 17:12:35,414 [main] DEBUG AbstractSaveEventListener.performSave():139 - saving [com.company.model.Test#<null>]
2005-09-21 17:12:35,445 [main] DEBUG AbstractSaveEventListener.performSaveOrReplicate():221 - executing insertions
2005-09-21 17:12:35,445 [main] DEBUG Cascade.cascade():237 - processing cascade ACTION_SAVE_UPDATE for: com.company.model.Test
2005-09-21 17:12:35,445 [main] DEBUG Cascade.cascade():259 - done processing cascade ACTION_SAVE_UPDATE for: com.company.model.Test
2005-09-21 17:12:35,460 [main] DEBUG Versioning.seed():35 - Seeding: 0
2005-09-21 17:12:35,460 [main] DEBUG AbstractEntityPersister.insert():1931 - Inserting entity: com.company.model.Test (native id)
2005-09-21 17:12:35,460 [main] DEBUG AbstractEntityPersister.insert():1932 - Version: 0
2005-09-21 17:12:35,460 [main] DEBUG SQL.log():344 -
2005-09-21 17:12:35,476 [main] DEBUG JDBCExceptionReporter.logExceptions():63 - could not insert: [com.company.model.Test] [/* insert com.company.model.Test */ insert into Test (version, name, created, creator, lastModified, modifier) values (?, ?, ?, ?, ?, ?)]
java.sql.SQLException: The SQL statement must not be null or empty.
   at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareStatement(ConnectionJDBC2.java:1990)
   at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:343)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.hibernate.util.GetGeneratedKeysHelper.prepareStatement(GetGeneratedKeysHelper.java:39)
   at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:424)
   at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1938)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2395)
   at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:37)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
   at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:269)
   at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
   at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:98)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
   at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:500)
   at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:494)
   at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:490)
   at com.company.dao.AbstractDAO.save(AbstractDAO.java:121)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 9:59 am 
Newbie

Joined: Wed May 04, 2005 9:37 am
Posts: 3
We're experiencing the same error where I'm using a Spring entity interceptor for our hibernate transaction manager. When I enable the interceptor, I get the exception:SQLException: The SQL statement must not be null or empty.. When I remove the interceptor, all my unit tests pass with flying colors. Googling for the error yields 0 results.

Essentially, the interceptor is logging certain events to an audit table in the database. When I run my debugger I see the onSave() method being called which essentially saves the entity to an ArrayList to be processed on postFlush(). My debugger never gets to the postFlush() method, which actually saves a copy of the entity and some information about the user to an audit table.

The interesting part here is that the exception actually shows the SQL it's using for the insert and it's not empty or null. Setting hibernate's show SQl property to true prints 'Hibernate: null'.

We're using Hibernate 3.1.b3 jars and Java 1.5.04. Switching back to 3.1.b1 solves the problem.


Interceptor StackTrace
Code:
Caused by: org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not insert: [com.mycompany.myapp.domain.model.ifc.Waste]; uncategorized SQLException for SQL [insert into myapp.WASTE (WASTE_DATE, WASTE_QUANTITY, OPT_LOCK, OU_ITEM_ID, STORE_NUMBER) values (?, ?, ?, ?, ?)]; SQL state [HY000]; error code [0]; The SQL statement must not be null or empty.; nested exception is java.sql.SQLException: The SQL statement must not be null or empty.
   at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:96)
   at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:257)
   at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
   at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:411)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:361)
   at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:593)
   at com.mycompany.common.domain.dao.hibernate.GenericHibernateDao.add(GenericHibernateDao.java:57)
   ... 37 more
Caused by: java.sql.SQLException: The SQL statement must not be null or empty.
   at net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareStatement(ConnectionJDBC2.java:1990)
   at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:394)
   at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:370)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at org.hibernate.util.GetGeneratedKeysHelper.prepareStatement(GetGeneratedKeysHelper.java:39)
   at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:424)
   at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:93)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1938)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2395)
   at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:37)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
   at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:269)
   at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
   at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:101)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
   at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
   at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
   at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:523)
   at org.hibernate.impl.SessionImpl.save(SessionImpl.java:513)
   at org.hibernate.impl.SessionImpl.save(SessionImpl.java:509)
   at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:596)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:356)
   ... 39 more


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 10:07 am 
Newbie

Joined: Wed May 04, 2005 9:37 am
Posts: 3
Sorry, forgot to mention that we're using MS SQL Server as our DB.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 11:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
could it be that Interceptor.prepareStatement() returns null instead of the original sql as it should ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 12:30 pm 
Newbie

Joined: Wed May 04, 2005 9:37 am
Posts: 3
Ahhh, that was the problem. Silly mistake. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 26, 2005 12:51 pm 
Beginner
Beginner

Joined: Wed Apr 13, 2005 10:34 am
Posts: 38
That was it. Thanks for the hint.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 4:03 pm 
Newbie

Joined: Mon Nov 03, 2003 11:38 am
Posts: 4
I am having the same error. What about the preparestatement? Is that something I need set?

Please give more detail about the solution.

Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 27, 2005 9:15 am 
Newbie

Joined: Mon Nov 03, 2003 11:38 am
Posts: 4
max wrote:
could it be that Interceptor.prepareStatement() returns null instead of the original sql as it should ?


I suspect this is my problem Could you please provide a little bit more hints that what I should do to fix this? I just don't know what I did wrong.

I havve followed the example from the user's guide but all I got was "The SQL statement must not be null or empty".

Thanks a lot for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 27, 2005 9:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
incredible...

Look at EmptyInterceptor.prepareStatement()

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 12:34 am 
Newbie

Joined: Mon Nov 03, 2003 11:38 am
Posts: 4
Thanks a lot. I was using a 3.0 hibernate.jar but thought I was on Hibernate 3.1. Eclipse did not generated onPreparedStatement() stub. After installing 3.1 jar, everything falls into place.

Thanks again.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.