-->
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: How to use a hibernate parameter list as a pseudo-table?
PostPosted: Wed Nov 29, 2017 10:16 am 
Newbie

Joined: Wed Nov 29, 2017 9:48 am
Posts: 2
I have the following (partial) SQL query:
Code:
  ... and OrderItem.id in (select oit.id from :cardserialNos csnt, OrderItem oit where csnt.THING between oit.cardSeqStartRange and oit.cardSeqEndRange) and ...

Furthermore, I have the following java code to support it:

Code:
  idsQuery.setParameterList("cardserialNos", criteria.getCardSerialNos());

My issue is, that in order to use the parameterlist as a pseudo-table the way I am above (taking the Cartesian product with the queried table so I can find out which card sequence ranges surround ANY of the cardserialNos), I need to learn what needs to go in the SQL query rather than csnt.THING.

Basically:
What is the proper column name of the hibernate parameter list pseudo-table?


Top
 Profile  
 
 Post subject: Re: How to use a hibernate parameter list as a pseudo-table?
PostPosted: Wed Nov 29, 2017 4:03 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
That's not supported via JPQL. You need to use Criteria API if you want to vary the Entity or Table name.


Top
 Profile  
 
 Post subject: Re: How to use a hibernate parameter list as a pseudo-table?
PostPosted: Thu Nov 30, 2017 6:57 am 
Newbie

Joined: Wed Nov 29, 2017 9:48 am
Posts: 2
I see. Unfortunate.

I have been reading up on the Criteria API, but I am not quite yet seeing how I would do this with it.
Is there any sort of tutorial you could point me to?


Top
 Profile  
 
 Post subject: Re: How to use a hibernate parameter list as a pseudo-table?
PostPosted: Thu Nov 30, 2017 7:09 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
We have a chapter dedicated to the Criteria API in our User Guide, which is a good place to start.

However, your query is not a typical one, so the chance of finding a tutorial that explain exactly your problem is rather low. Hence, my suggestion. Just Google "JPA Criteria API" + whatever you are interested in doing.

This way, you can easily find the following answers:

1. This StackOverflow answer shows how to use a Subquery for the IN clause.
2. This StackOverflow answer shows how to create the Cartesian Product for the subquery.


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.