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.  [ 2 posts ] 
Author Message
 Post subject: InvalidDataAccessResourceUsageException
PostPosted: Fri Jun 25, 2010 8:33 am 
Newbie

Joined: Fri Jun 25, 2010 8:26 am
Posts: 2
Hello,

I have a problem with a very basic query

Code:
"from Customers customer where customer.name='"+companyName+"'"


All the db colls are mapped (checked it a thousend times) but still i get the error below

Code:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [select customers0_.id as id0_, customers0_.name as name0_, customers0_.address as address0_, customers0_.postalCode as postalCode0_, customers0_.city as city0_, customers0_.telephone as telephone0_ from saktiehuis.saktiehuis.customers customers0_ where customers0_.name='test']; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query


The thing i noticed is this "from saktiehuis.saktiehuis.customers customers0_" saktiehuis is the database but hibernate puts it twice in the generated sql query. Can someone help me? Please!

Grtz


Top
 Profile  
 
 Post subject: Re: InvalidDataAccessResourceUsageException
PostPosted: Sun Jun 27, 2010 8:41 am 
Newbie

Joined: Fri Jun 25, 2010 8:26 am
Posts: 2
Nailed it!

For everyone facing the same problem, here is the solution.
I configured a default_scheme in my hibernate configuration. I also configured hibernate to scan the domain classes because I used annotations. In the domain classes I added the following rule

Code:
@Table(name = "`products`", catalog = "saktiehuis")


This is where it went wrong. hibernate now used the default_schema setting and the catalog setting from the domain classes to generate the sql, this caused the double db in the query. To solve this simply remove the default_schema setting or the catalog from the domain classes.


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