java.sql.SQLException

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.

  • Hi I'm using the Criteria API to build a complex query in response to variable user input but the SQL generated is broken in the following circumstance: I have 2 tables AuditEvent and AuditDetails - a simple parent/child relationship. I'm wanting to find AuditDetail objects using criteria on the corresponding AuditEvent object. So I do this: Criteria crit = session.createCriteria(AuditDetail.class); crit.setFetchMode("auditEvent", FetchMode.EAGER); if (userName != null) crit.createCriteria("auditEvent").add(Expression.eq("userName", userName)); if (ipAddress != null) crit.createCriteria("auditEvent").add(Expression.eq("ipAddress", ipAddress)); If I pass in only a userName or an ipAddress then the generated SQL is correct, however if I pass both, then the createCriteria("auditEvent") gets called twice and the following (erroneous) SQL results: select this.id as id1_, this.auditEvent as auditEvent1_, this.classKey as classKey1_, this.dataType as dataType1_, this.fieldKey as fieldKey1_, this.newValue as newValue1_, this.objectId as objectId1_, this.objectVersion as objectVe8_1_, this.oldValue as oldValue1_, x1_.id as id0_, x1_.dateTime as dateTime0_, x1_.ipAddress as ipAddress0_, x1_.userName as userName0_ from AuditDetail this inner join AuditEvent x1_ on this.auditEvent=x1_.id where x0_.userName=? and x1_.ipAddress=? and ((this.oldValue is null and this.newValue is not null)) which results in: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]The column prefix 'x0_' does not match with a table name or alias name used in the query. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSCursorRequest.openCursor(Unknown Source) at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.execute(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:205) at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87) at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) at net.sf.hibernate.loader.Loader.doList(Loader.java:955) at net.sf.hibernate.loader.Loader.list(Loader.java:946) at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:121) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3609) at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238) ... If I change my code so that the createCriteria("auditEvent") line only gets called once and I re-use it, it works fine, so the issue seems to be with calling it more than once. As a side note, it is a little inconvenient to have to store the result of calling createCriteria. It would be nice for it to lookup a previously created Criteria, and return it if it had already been created, and otherwise create a new Criteria. Can supply more detail such as mapping documents, etc. if required. Craig
    via by Craig Shearer,
  • Hi I'm using the Criteria API to build a complex query in response to variable user input but the SQL generated is broken in the following circumstance: I have 2 tables AuditEvent and AuditDetails - a simple parent/child relationship. I'm wanting to find AuditDetail objects using criteria on the corresponding AuditEvent object. So I do this: Criteria crit = session.createCriteria(AuditDetail.class); crit.setFetchMode("auditEvent", FetchMode.EAGER); if (userName != null) crit.createCriteria("auditEvent").add(Expression.eq("userName", userName)); if (ipAddress != null) crit.createCriteria("auditEvent").add(Expression.eq("ipAddress", ipAddress)); If I pass in only a userName or an ipAddress then the generated SQL is correct, however if I pass both, then the createCriteria("auditEvent") gets called twice and the following (erroneous) SQL results: select this.id as id1_, this.auditEvent as auditEvent1_, this.classKey as classKey1_, this.dataType as dataType1_, this.fieldKey as fieldKey1_, this.newValue as newValue1_, this.objectId as objectId1_, this.objectVersion as objectVe8_1_, this.oldValue as oldValue1_, x1_.id as id0_, x1_.dateTime as dateTime0_, x1_.ipAddress as ipAddress0_, x1_.userName as userName0_ from AuditDetail this inner join AuditEvent x1_ on this.auditEvent=x1_.id where x0_.userName=? and x1_.ipAddress=? and ((this.oldValue is null and this.newValue is not null)) which results in: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]The column prefix 'x0_' does not match with a table name or alias name used in the query. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSCursorRequest.openCursor(Unknown Source) at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.execute(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:205) at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87) at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) at net.sf.hibernate.loader.Loader.doList(Loader.java:955) at net.sf.hibernate.loader.Loader.list(Loader.java:946) at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:121) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3609) at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238) ... If I change my code so that the createCriteria("auditEvent") line only gets called once and I re-use it, it works fine, so the issue seems to be with calling it more than once. As a side note, it is a little inconvenient to have to store the result of calling createCriteria. It would be nice for it to lookup a previously created Criteria, and return it if it had already been created, and otherwise create a new Criteria. Can supply more detail such as mapping documents, etc. if required. Craig
    via by Craig Shearer,
  • Hibernate try to execute this typical Oracle syntax on my SqlServer 2000 as shown below: my id configuration is: <id name="pkid" type="long" column="pkid" unsaved-value="null"> <generator class="native"> <param name="sequence">seq_pro_aoo</param> </generator> </id> Trace log: Hibernate: select seq_pro_aoo.nextval from dual 13-ago-2003 9.32.40 it.saga.library.persistence.PersistenceConfiguration getSessionFactory INFO: SessionFactory found! 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logExceptions AVVERTENZA: SQL Error: 208, SQLState: 42S02 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logExceptions GRAVE: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'dual'. 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logExceptions AVVERTENZA: SQL Error: 16945, SQLState: HY000 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logExceptions GRAVE: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]The cursor was not declared. 13-ago-2003 9.32.40 net.sf.hibernate.JDBCException <init> GRAVE: Could not save object java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'dual'. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSCursorRequest.openCursor(Unknown Source) at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.execute(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source) at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:271) at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:271) at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:271) at net.sf.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:61) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:599) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1202) at it.saga.library.persistence.PersistentStatelessBean.save(PersistentStatelessBean.java:179) at it.saga.pubblici.protocollo.impl.BLGProAOOBean.save(BLGProAOOBean.java:38) at BLGProAOO_StatelessSessionBeanWrapper30.save(BLGProAOO_StatelessSessionBeanWrapper30.java:180) 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:324) at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119) at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:536) 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: SQL Warning: 0, SQLState: 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to Protocollo 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: SQL Warning: 0, SQLState: 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed database context to 'Protocollo'. 13-ago-2003 9.32.41 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: SQL Warning: 0, SQLState: 13-ago-2003 9.32.41 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: [Microsoft][SQLServer 2000 Driver for JDBC]Language changed to us_english 13-ago-2003 9.32.41 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: SQL Warning: 0, SQLState: 13-ago-2003 9.32.41 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed language setting to us_english. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'dual'. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
    via by Fabio Parise,
  • ODI Designer - Datastore issue
    via by 856608,
  • Hibernate try to execute this typical Oracle syntax on my SqlServer 2000 as shown below: my id configuration is: <id name="pkid" type="long" column="pkid" unsaved-value="null"> <generator class="native"> <param name="sequence">seq_pro_aoo</param> </generator> </id> Trace log: Hibernate: select seq_pro_aoo.nextval from dual 13-ago-2003 9.32.40 it.saga.library.persistence.PersistenceConfiguration getSessionFactory INFO: SessionFactory found! 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logExceptions AVVERTENZA: SQL Error: 208, SQLState: 42S02 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logExceptions GRAVE: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'dual'. 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logExceptions AVVERTENZA: SQL Error: 16945, SQLState: HY000 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logExceptions GRAVE: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]The cursor was not declared. 13-ago-2003 9.32.40 net.sf.hibernate.JDBCException <init> GRAVE: Could not save object java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'dual'. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSCursorRequest.openCursor(Unknown Source) at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.execute(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source) at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:271) at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:271) at com.evermind.sql.FilterPreparedStatement.executeQuery(FilterPreparedStatement.java:271) at net.sf.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:61) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:599) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1202) at it.saga.library.persistence.PersistentStatelessBean.save(PersistentStatelessBean.java:179) at it.saga.pubblici.protocollo.impl.BLGProAOOBean.save(BLGProAOOBean.java:38) at BLGProAOO_StatelessSessionBeanWrapper30.save(BLGProAOO_StatelessSessionBeanWrapper30.java:180) 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:324) at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119) at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803) at java.lang.Thread.run(Thread.java:536) 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: SQL Warning: 0, SQLState: 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to Protocollo 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: SQL Warning: 0, SQLState: 13-ago-2003 9.32.40 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed database context to 'Protocollo'. 13-ago-2003 9.32.41 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: SQL Warning: 0, SQLState: 13-ago-2003 9.32.41 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: [Microsoft][SQLServer 2000 Driver for JDBC]Language changed to us_english 13-ago-2003 9.32.41 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: SQL Warning: 0, SQLState: 13-ago-2003 9.32.41 net.sf.hibernate.util.JDBCExceptionReporter logWarnings AVVERTENZA: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed language setting to us_english. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'dual'. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
    via by Fabio Parise,
  • Problem with calculated attribute
    via by 95318,
    • java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]The column prefix 'x0_' does not match with a table name or alias name used in the query. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSCursorRequest.openCursor(Unknown Source) at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.execute(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:205) at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87) at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133) at net.sf.hibernate.loader.Loader.doList(Loader.java:955) at net.sf.hibernate.loader.Loader.list(Loader.java:946) at net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:121) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3609) at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)

    Users with the same issue

    rp
    1 times, last one,
    Unknown visitor1 times, last one,