-->
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.  [ 4 posts ] 
Author Message
 Post subject: "Syntax error or access violation...in using IN clause&
PostPosted: Sun Jun 13, 2004 3:06 am 
Newbie

Joined: Sun Apr 04, 2004 5:00 am
Posts: 13
Hello All...

while using the SubQueries in hibernate i got this error...
can anyone help me out in getting this cleared!
thanx a bunch!

Caused by: java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax near 'select inventory1_.PS_ID from clts_inventory inventory1_ where (inventory1_.STOR' at line 1"

Hibernate Query is :

Hibernate: select productspe0_.PS_DESCRIPTION as x0_0_ from clts_prdt_spec productspe0_ where (productspe0_.PS_DESCRIPTION like 'c%' )and(productspe0_.PS_ID in(select inventory1_.PS_ID from clts_inventory inventory1_ where (inventory1_.STORE_ID=303 )))

My Query is :

select ProductSpecification.ProductDescription from productspecification.domain.ProductSpecification ProductSpecification where ProductSpecification.ProductDescription like 'c%' and ProductSpecification.ProductSpecificationId in (select Inventory.ProductSpecification.ProductSpecificationId from inventory.domain.Inventory Inventory where Inventory.Store.StoreId=303)

Tried using this query also...:

Hibernate Query is :

Hibernate: select productspe0_.PS_DESCRIPTION as x0_0_ from clts_prdt_spec productspe0_, clts_inventory inventory1_ where (productspe0_.PS_DESCRIPTION like 'c%' )and(productspe0_.PS_ID in(select inventory2_.PS_ID from clts_inventory inventory2_ where (inventory2_.STORE_ID=303 )))

My Query is :

select ProductSpecification.ProductDescription from productspecification.domain.ProductSpecification ProductSpecification,
inventory.domain.Inventory Inventory
where ProductSpecification.ProductDescription like 'c%' and ProductSpecification.ProductSpecificationId in (select Inventory.ProductSpecification.ProductSpecificationId from inventory.domain.Inventory Inventory where Inventory.Store.StoreId=303)

am i wrong in my query?...or its in accessing the Data???

-Munas.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 4:54 am 
Newbie

Joined: Sun Apr 04, 2004 5:00 am
Posts: 13
dear all....

i didnt get any solution....but i tried something like this...

select ProductSpecification.ProductDescription from productspecification.domain.ProductSpecification ProductSpecification where ProductSpecification.ProductDescription like 'p%' and ProductSpecification.ProductSpecificationId in (101,103,104)

this query works fine....but if i substitute the IN cluase () with other select query(select ID from Store), it gives the error...i m using MySql as Database....!

tips on this will be extremely appreciated!
thanx a bunch!

-Munas.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 5:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Are you using a mysql version that supports subselects?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 5:48 am 
Newbie

Joined: Sun Apr 04, 2004 5:00 am
Posts: 13
Dear Michael..

My MySql is not SubQuery Supported version...
i thought Hibernate will make it easy ...!

so i have to use Tow Queries to get the desired o/p...like...
1. get all the Product.Id & Descriptions
2. get all the product ids from Store and
make it as a string like (123,234,345...)
then compare both!

is there any other alternative solution for this (using singe HQL)?

-Munas.


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