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.

Hibernate JIRA | Craig Shearer | 1 decade ago
  1. 0

    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

    Hibernate JIRA | 1 decade ago | Craig Shearer
    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.
  2. 0

    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

    Hibernate JIRA | 1 decade ago | Craig Shearer
    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.
  3. 0

    Cannot access portal after datbase-transfer from cloudscape to SQL Server

    Google Groups | 10 years ago | Hari
    com.ibm.wps.util.DataBackendException: EJPDB0064E: SQL Exception caught when initializing the IDFactory.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    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)

    Hibernate JIRA | 1 decade ago | Fabio Parise
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'dual'.
  6. 0

    No repsonse when create master repository in SQL 2005

    Oracle Community | 7 years ago | Thomas Chung
    com.sunopsis.tools.core.exception.SnpsRuntimeException: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 (""): Data type 0x38 is unknown.

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. 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()
    2. com.microsoft.jdbc
      BasePreparedStatement.executeQuery
      1. com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
      2. com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
      3. com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
      4. com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
      5. com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
      6. com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
      7. com.microsoft.jdbc.sqlserver.tds.TDSCursorRequest.openCursor(Unknown Source)
      8. com.microsoft.jdbc.sqlserver.SQLServerImplStatement.execute(Unknown Source)
      9. com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
      10. com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
      11. com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
      11 frames
    3. Commons DBCP
      DelegatingPreparedStatement.executeQuery
      1. org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:205)
      1 frame
    4. net.sf.hibernate
      CriteriaImpl.list
      1. net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
      2. net.sf.hibernate.loader.Loader.getResultSet(Loader.java:800)
      3. net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
      4. net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
      5. net.sf.hibernate.loader.Loader.doList(Loader.java:955)
      6. net.sf.hibernate.loader.Loader.list(Loader.java:946)
      7. net.sf.hibernate.loader.CriteriaLoader.list(CriteriaLoader.java:121)
      8. net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3609)
      9. net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
      9 frames