Unfortunately this doesn't work and I've failed to understand why. So:
The DBMS we're using is MS SQL Server 2000.
The JDBC driver is jTDS, a connection pool is set up in Tomcat's server.xml and distributed with JNDI - Hibernate has no problems connecting.
I get valid SQL queries from Hibernate in the logs and I can execute them successfully in Microsoft Management Console.
The error I get is "Invalid object name" as seen below and it occurs for any class that I specify the schema-attribute for in the hibernate mapping file.
Before reading on, is the JDBC-driver from jTDS insufficent since it implements JDBC 2.0 and not 3.0?
Are there any known issues with MS SQL and/or jTDS when using multiple schemas/catalogs?
Code:
14:07:27,965 INFO DatasourceConnectionProvider:51 - Using datasource: java:comp/env/jdbc/novaq
14:07:27,975 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
14:07:28,165 INFO SettingsFactory:102 - Use scrollable result sets: true
14:07:28,165 INFO SettingsFactory:105 - Use JDBC3 getGeneratedKeys(): false
14:07:28,165 INFO SettingsFactory:108 - Optimize cache for minimal puts: false
14:07:28,165 INFO SettingsFactory:117 - Query language substitutions: {}
14:07:28,165 INFO SettingsFactory:128 - cache provider: net.sf.ehcache.hibernate.Provider
14:07:28,175 INFO Configuration:1080 - instantiating and configuring caches
14:07:28,426 INFO SessionFactoryImpl:119 - building session factory
14:07:30,829 INFO SessionFactoryObjectFactory:82 - no JNDI name configured
QUERY: FROM ReceiptGoods r WHERE r.documentNumber LIKE 'IL06209'
14:07:31,010 DEBUG SQL:237 - select receiptgoo0_.[No.] as y1_, receiptgoo0_.[Document Date] as y2_, receiptgoo0_.vendor as vendor from Attain.[NovAseptic AB Skarp$Purch_ Rcpt_ Header] receiptgoo0_ where (receiptgoo0_.[No.] LIKE 'IL06209' )
14:07:31,070 WARN JDBCExceptionReporter:38 - SQL Error: 208, SQLState: S1000
14:07:31,070 ERROR JDBCExceptionReporter:46 - Invalid object name 'Attain.NovAseptic AB Skarp$Purch_ Rcpt_ Header'.
14:07:31,070 WARN JDBCExceptionReporter:38 - SQL Error: 208, SQLState: S1000
14:07:31,080 ERROR JDBCExceptionReporter:46 - Invalid object name 'Attain.NovAseptic AB Skarp$Purch_ Rcpt_ Header'.
14:07:31,080 ERROR JDBCExceptionReporter:38 - Could not execute query
java.sql.SQLException: Invalid object name 'Attain.NovAseptic AB Skarp$Purch_ Rcpt_ Header'.
at net.sourceforge.jtds.jdbc.SqlMessage.toSQLException(Unknown Source)
at net.sourceforge.jtds.jdbc.SQLWarningChain.addOrReturn(Unknown Source)
at net.sourceforge.jtds.jdbc.TdsStatement.getMoreResults(Unknown Source)
at net.sourceforge.jtds.jdbc.TdsStatement.executeCallImpl(Unknown Source)
at net.sourceforge.jtds.jdbc.TdsStatement.internalExecuteCall(Unknown Source)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.execute(Unknown Source)
at net.sourceforge.jtds.jdbc.PreparedStatement_base.executeQuery(Unknown Source)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:179)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:795)
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:950)
at net.sf.hibernate.loader.Loader.list(Loader.java:941)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483)
Thanks for any help.