java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'.

Hibernate JIRA | Jon Chase | 1 decade ago
  1. 0

    (from http://forum.hibernate.org/viewtopic.php?p=2190300#2190300) Problem: Hibernate pukes (see stack trace) because of the brackets [] around a column name (Site Type (yes, there is a space in the column name)) in the WHERE clause of a SET mapping. <set name="tableSubAs" inverse="true" where="[Site Type]=1" > How do I get around this? I've tried backticks ` and apostrophes ' but these don't work either. Detailed description: I'm working with a legacy database which has a table (TableA) with a column whose name includes a space. The column name is "Site Type". It just so happens that this column is a discriminator value for subclasses to TableA (like TableSubA). In my mapping document, I have a property mapping for this column that works just fine: <property name="siteType" type="byte" column="[Site Type]" length="3" /> Notice the brackets [ ] used around the column name b/c of the space. However, another table (TableB) contains a set of TableSubA's (the subclass). In order for the set to only contain the subclass, I need to use the WHERE clause in the set mapping (see FAQ http://www.hibernate.org/117.html#A13) to specify the included elements should have a Site Type of 1. <set name="tableSubAs" inverse="true" where="[Site Type]=1" > <key> <column name="id" /> </key> <one-to-many class="foo.TableSubA" /> </set> Stack trace: org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. 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.SQLServerImplStatement.getNextResultType(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(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 net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:83) at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:794) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:188) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:909) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:884) at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:80) at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284) at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3133) at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:331) at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3007) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:137) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:830) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:850) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:420) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2044) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1918) at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1847) at org.springframework.orm.hibernate.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:221) at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:147) at org.springframework.orm.hibernate.HibernateTemplate.load(HibernateTemplate.java:219) at dars.clientmap.dao.hibernate.StateDaoHibernate.loadState(StateDaoHibernate.java:21) at dars.clientmap.dao.AbstractStateDaoTest.testLoadStateRealState(AbstractStateDaoTest.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:397) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:281) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:173) org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. 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.SQLServerImplStatement.getNextResultType(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(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 net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:83) at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:794) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:188) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:909) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:884) at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:80) at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284) at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3133) at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:331) at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3007) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:137) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:830) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:850) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:420) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2044) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1918) at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1847) at org.springframework.orm.hibernate.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:221) at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:147) at org.springframework.orm.hibernate.HibernateTemplate.load(HibernateTemplate.java:219) at dars.clientmap.dao.hibernate.StateDaoHibernate.loadState(StateDaoHibernate.java:21) at dars.clientmap.dao.AbstractStateDaoTest.testLoadStateRealState(AbstractStateDaoTest.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:397) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:281) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:173)

    Hibernate JIRA | 1 decade ago | Jon Chase
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'.
  2. 0

    (from http://forum.hibernate.org/viewtopic.php?p=2190300#2190300) Problem: Hibernate pukes (see stack trace) because of the brackets [] around a column name (Site Type (yes, there is a space in the column name)) in the WHERE clause of a SET mapping. <set name="tableSubAs" inverse="true" where="[Site Type]=1" > How do I get around this? I've tried backticks ` and apostrophes ' but these don't work either. Detailed description: I'm working with a legacy database which has a table (TableA) with a column whose name includes a space. The column name is "Site Type". It just so happens that this column is a discriminator value for subclasses to TableA (like TableSubA). In my mapping document, I have a property mapping for this column that works just fine: <property name="siteType" type="byte" column="[Site Type]" length="3" /> Notice the brackets [ ] used around the column name b/c of the space. However, another table (TableB) contains a set of TableSubA's (the subclass). In order for the set to only contain the subclass, I need to use the WHERE clause in the set mapping (see FAQ http://www.hibernate.org/117.html#A13) to specify the included elements should have a Site Type of 1. <set name="tableSubAs" inverse="true" where="[Site Type]=1" > <key> <column name="id" /> </key> <one-to-many class="foo.TableSubA" /> </set> Stack trace: org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. 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.SQLServerImplStatement.getNextResultType(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(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 net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:83) at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:794) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:188) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:909) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:884) at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:80) at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284) at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3133) at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:331) at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3007) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:137) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:830) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:850) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:420) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2044) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1918) at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1847) at org.springframework.orm.hibernate.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:221) at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:147) at org.springframework.orm.hibernate.HibernateTemplate.load(HibernateTemplate.java:219) at dars.clientmap.dao.hibernate.StateDaoHibernate.loadState(StateDaoHibernate.java:21) at dars.clientmap.dao.AbstractStateDaoTest.testLoadStateRealState(AbstractStateDaoTest.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:397) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:281) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:173) org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. org.springframework.jdbc.BadSqlGrammarException: Bad SQL grammar [null] in task 'HibernateAccessor'; nested exception is: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'. 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.SQLServerImplStatement.getNextResultType(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(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 net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:83) at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:794) at net.sf.hibernate.loader.Loader.doQuery(Loader.java:188) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:909) at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:884) at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:80) at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284) at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3133) at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:331) at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3007) at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:137) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:830) at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:850) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57) at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49) at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:420) at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2044) at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1918) at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1847) at org.springframework.orm.hibernate.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:221) at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:147) at org.springframework.orm.hibernate.HibernateTemplate.load(HibernateTemplate.java:219) at dars.clientmap.dao.hibernate.StateDaoHibernate.loadState(StateDaoHibernate.java:21) at dars.clientmap.dao.AbstractStateDaoTest.testLoadStateRealState(AbstractStateDaoTest.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:397) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:281) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:173)

    Hibernate JIRA | 1 decade ago | Jon Chase
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid column name 'Site clients0_.Type'.
  3. 0

    If you have in your mappings set fetch="join" and order-by="" for child collection like in this mapping: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="test.model"> <class name="Cat" table="CAT"> <id name="catId" column="CAT_ID" type="java.lang.Integer"> <generator class="native"/> </id> <property name="name" column="NAME" type="java.lang.String" /> <property name="color" column="COLOR" type="java.lang.String" /> <property name="gender" column="GENDER" type="java.lang.String" /> <set name="kittens" fetch="join" cascade="all-delete-orphan" inverse="true" order-by="name" > <key column="MOTHER_ID"/> <one-to-many class="Cat"/> </set> </class> </hibernate-mapping> adding Projection to criteria will have in a result incorrect query generated and execution will fail, like that: Hibernate: select count(*) as y0_ from CAT this_ left outer join CAT kittens2_ on this_.CAT_ID=kittens2_.MOTHER_ID where this_.COLOR=? order by kittens2_.name 14:12:45,163 ERROR JDBCExceptionReporter:72 - [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Column name 'kittens2_.NAME' is invalid in the ORDER BY clause because it is not contained in an aggregate function and there is no GROUP BY clause. org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:1596) at org.hibernate.loader.Loader.list(Loader.java:1577) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1322) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300) at test.test.Test.test(Test.java:62) at test.test.Test.main(Test.java:79) Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Column name 'kittens2_.NAME' is invalid in the ORDER BY clause because it is not contained in an aggregate function and there is no GROUP BY clause. 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.SQLServerImplStatement.getNextResultType(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(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.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120) at org.hibernate.loader.Loader.getResultSet(Loader.java:1272) at org.hibernate.loader.Loader.doQuery(Loader.java:391) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218) at org.hibernate.loader.Loader.doList(Loader.java:1593) ... 6 more Source code for criteria is: List results = session.createCriteria(Cat.class) .setProjection( Projections.rowCount() ) .add( Restrictions.eq("color", "BLACK") ) .list(); If you remove fetch="join" everything works just fine. Even if you will use subcriteria with child attributes. Changes in any other attributes have no effect.

    Hibernate JIRA | 1 decade ago | Vasyl Zhabko
    org.hibernate.exception.GenericJDBCException: could not execute query
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Probelm with Microsoft SQL JDBC driver SP1

    Oracle Community | 1 decade ago | 843854
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Line 1: Incorrect syntax near '{'.
  6. 0

    If you have in your mappings set fetch="join" and order-by="" for child collection like in this mapping: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="test.model"> <class name="Cat" table="CAT"> <id name="catId" column="CAT_ID" type="java.lang.Integer"> <generator class="native"/> </id> <property name="name" column="NAME" type="java.lang.String" /> <property name="color" column="COLOR" type="java.lang.String" /> <property name="gender" column="GENDER" type="java.lang.String" /> <set name="kittens" fetch="join" cascade="all-delete-orphan" inverse="true" order-by="name" > <key column="MOTHER_ID"/> <one-to-many class="Cat"/> </set> </class> </hibernate-mapping> adding Projection to criteria will have in a result incorrect query generated and execution will fail, like that: Hibernate: select count(*) as y0_ from CAT this_ left outer join CAT kittens2_ on this_.CAT_ID=kittens2_.MOTHER_ID where this_.COLOR=? order by kittens2_.name 14:12:45,163 ERROR JDBCExceptionReporter:72 - [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Column name 'kittens2_.NAME' is invalid in the ORDER BY clause because it is not contained in an aggregate function and there is no GROUP BY clause. org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.doList(Loader.java:1596) at org.hibernate.loader.Loader.list(Loader.java:1577) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1322) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:300) at test.test.Test.test(Test.java:62) at test.test.Test.main(Test.java:79) Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Column name 'kittens2_.NAME' is invalid in the ORDER BY clause because it is not contained in an aggregate function and there is no GROUP BY clause. 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.SQLServerImplStatement.getNextResultType(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source) at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(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.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120) at org.hibernate.loader.Loader.getResultSet(Loader.java:1272) at org.hibernate.loader.Loader.doQuery(Loader.java:391) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218) at org.hibernate.loader.Loader.doList(Loader.java:1593) ... 6 more Source code for criteria is: List results = session.createCriteria(Cat.class) .setProjection( Projections.rowCount() ) .add( Restrictions.eq("color", "BLACK") ) .list(); If you remove fetch="join" everything works just fine. Even if you will use subcriteria with child attributes. Changes in any other attributes have no effect.

    Hibernate JIRA | 1 decade ago | Vasyl Zhabko
    org.hibernate.exception.GenericJDBCException: could not execute query

    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]Invalid column name 'Site clients0_.Type'.

      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.SQLServerImplStatement.getNextResultType(Unknown Source)
      8. com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
      9. com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
      10. com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
      11. com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
      12. com.microsoft.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
      13. com.microsoft.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
      13 frames
    3. net.sf.hibernate
      SessionImpl.load
      1. net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:83)
      2. net.sf.hibernate.loader.Loader.getResultSet(Loader.java:794)
      3. net.sf.hibernate.loader.Loader.doQuery(Loader.java:188)
      4. net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
      5. net.sf.hibernate.loader.Loader.loadCollection(Loader.java:909)
      6. net.sf.hibernate.loader.Loader.loadCollection(Loader.java:884)
      7. net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:80)
      8. net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
      9. net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3133)
      10. net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:331)
      11. net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3007)
      12. net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:137)
      13. net.sf.hibernate.loader.Loader.loadEntity(Loader.java:830)
      14. net.sf.hibernate.loader.Loader.loadEntity(Loader.java:850)
      15. net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57)
      16. net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49)
      17. net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:420)
      18. net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2044)
      19. net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1918)
      20. net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1847)
      20 frames
    4. Hibernate
      HibernateTemplate.load
      1. org.springframework.orm.hibernate.HibernateTemplate$3.doInHibernate(HibernateTemplate.java:221)
      2. org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:147)
      3. org.springframework.orm.hibernate.HibernateTemplate.load(HibernateTemplate.java:219)
      3 frames
    5. dars.clientmap.dao
      AbstractStateDaoTest.testLoadStateRealState
      1. dars.clientmap.dao.hibernate.StateDaoHibernate.loadState(StateDaoHibernate.java:21)
      2. dars.clientmap.dao.AbstractStateDaoTest.testLoadStateRealState(AbstractStateDaoTest.java:31)
      2 frames
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      4. java.lang.reflect.Method.invoke(Unknown Source)
      4 frames
    7. JUnit
      TestSuite.run
      1. junit.framework.TestCase.runTest(TestCase.java:154)
      2. junit.framework.TestCase.runBare(TestCase.java:127)
      3. junit.framework.TestResult$1.protect(TestResult.java:106)
      4. junit.framework.TestResult.runProtected(TestResult.java:124)
      5. junit.framework.TestResult.run(TestResult.java:109)
      6. junit.framework.TestCase.run(TestCase.java:118)
      7. junit.framework.TestSuite.runTest(TestSuite.java:208)
      8. junit.framework.TestSuite.run(TestSuite.java:203)
      8 frames
    8. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:397)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:281)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:173)
      3 frames