-->
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.  [ 3 posts ] 
Author Message
 Post subject: "databasename.tablename" causing error Invalid Object Name
PostPosted: Thu Jan 28, 2010 11:06 pm 
Beginner
Beginner

Joined: Sun Dec 28, 2008 6:01 pm
Posts: 24
Hi,

Hibernate is generating an insert statement with "database.tablename", which is causing an error Invalid Object Name. Here is the format of the query generated by hibernate...

insert into xyz.[tablename] (col1, col2, col3) values (?, ?, ?)

Here is my environment...
Java 1.6
Hibernate 3.2.7.ga
SQL Server 2005

Any clues please?

Thanks


Top
 Profile  
 
 Post subject: Re: "databasename.tablename" causing error Invalid Object Name
PostPosted: Sat Jan 30, 2010 5:43 pm 
Beginner
Beginner

Joined: Sun Dec 28, 2008 6:01 pm
Posts: 24
Hi Folks,

I am stuck with this problem for over 2 days now and cannot figure out the cause. It seems everything is setup fine, but still have this Invalid object name 'database.ACCOUNT'. It should be 'database.dbo.ACCOUNT' or it should be just be 'Account'.

To eliminate the db setup problem, I tried with the database which works fine with another application with same configuration, and it gives the same error back with this database and my application. Here are the details...

My Spring configuration...

Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
   xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
   xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:osgi="http://www.springframework.org/schema/osgi"
   xsi:schemaLocation="
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">

   

   <context:annotation-config />
   <tx:annotation-driven mode="aspectj" />   
   <context:component-scan base-package="com.xxxx.yyy.zzz.dao" />
   
      
      
      
     <bean id="basicDataSource" class="org.apache.commons.dbcp.BasicDataSource"
      p:url="jdbc:jtds:sqlserver://localhost:1433/ebsdb"
      p:username="ebs_user"
      p:password="ebs_user"      
      p:driverClassName="net.sourceforge.jtds.jdbc.Driver"
      />
   
   <bean id="hibernateJpaVendorAdapter"
      class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
      p:databasePlatform="org.hibernate.dialect.SQLServerDialect"
      p:showSql="true"/>   

   <bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
      p:dataSource-ref="basicDataSource"
      p:jpaVendorAdapter-ref="hibernateJpaVendorAdapter"
      p:persistenceUnitName="eds-jpa" />
      
   <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
      p:entityManagerFactory-ref="entityManagerFactory"/>   
</beans>


Here is the error I get...
Code:
-------------------------------------------------------------------------------
Test set: com.xxxxx.yyy.zzz.test.zzzRepositoryTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 11.415 sec <<< FAILURE!
testGetDAO(com.xxxxx.yyy.zzz.test.zzzRepositoryTest)  Time elapsed: 0.329 sec  <<< ERROR!
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
   at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
   at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:128)
   at com.xxxxx.yyy.zzz.dao.impl.GenericDAOImpl.getById(GenericDAOImpl.java:44)
   at com.xxxxx.yyy.zzz.test.zzzRepositoryTest.testGetDAO(zzzRepositoryTest.java:27)
   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:597)
   at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:160)
   at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
   at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
   at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
   at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
   at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:160)
   at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
   at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
   at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
   at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
   at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
   at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
   at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
   at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
   at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
   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:597)
   at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
   at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.doList(Loader.java:2216)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
   at org.hibernate.loader.Loader.list(Loader.java:2099)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
   at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
   at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:88)
   ... 29 more
Caused by: com.inet.tds.Tds4SQLException: Msg 208, Level 16, State 1, Line 1, Sqlstate S0002
[b][MCNAME]Invalid object name 'JJJJJ.ACCOUNT'.[/b]
   at com.inet.tds.aa.a(Unknown Source)
   at com.inet.tds.n.b(Unknown Source)
   at com.inet.tds.n.a(Unknown Source)
   at com.inet.tds.p.c(Unknown Source)
   at com.inet.tds.p.a(Unknown Source)
   at com.inet.tds.p.b(Unknown Source)
   at com.inet.tds.bg.g(Unknown Source)
   at com.inet.tds.bg.executeQuery(Unknown Source)
   at org.apache.commons.dbcp.DelegatingPreparzzztatement.executeQuery(DelegatingPreparzzztatement.java:93)
   at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
   at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
   at org.hibernate.loader.Loader.doQuery(Loader.java:674)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.doList(Loader.java:2213)
   ... 37 more



I really appreciate any clues to resolve this issue.

_________________
______________________________________
Please do RATE if this post was helpful


Top
 Profile  
 
 Post subject: Re: "databasename.tablename" causing error Invalid Object Name
PostPosted: Sun Jan 31, 2010 11:12 pm 
Beginner
Beginner

Joined: Sun Dec 28, 2008 6:01 pm
Posts: 24
Issue Resolved. I am not sharing the resolution, since this has nothing to do with hibernate or database setup.

_________________
______________________________________
Please do RATE if this post was helpful


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.