Using derived tables with JPAQuery

305 views
Skip to first unread message

Frodo S

unread,
Feb 17, 2015, 1:48:11 PM2/17/15
to quer...@googlegroups.com
Hy, 

I need to use derived tables with the object JPAQuery. For example in the next case:

JPAQuery q = new JPAQuery(em);
q.from(derivedTable); //derived table
q.innerJoin(derivedTable.id, QUser.user ) // inner join with real table
........


I need derived tables not subquery; already tried it and is really slow. So I need in the from clause to set a derived table and at the same time doing an inner join with other real table connecting both tables or other option would be doing a from operation with a real table and an innerjoin with a derived table but I dont know how to do it in the documentation. An example would be really aprecciated


Thanks a lot

Frodo S

unread,
Feb 17, 2015, 1:52:41 PM2/17/15
to quer...@googlegroups.com
I need to do something like this:

 SELECT u.last_name, 
       a.state
FROM   User AS u,
       (SELECT user_id, state FROM Address) AS a
WHERE  u.id = a.user_id;


Thanks a lot

Timo Westkämper

unread,
Feb 17, 2015, 1:52:54 PM2/17/15
to Querydsl on behalf of Frodo S
Hi.

I don't think derived tables are supported in JPQL. You will need to use SQL for that.

JPAQuery is restricted by the expressiveness of JPQL.

Br,
Timo

--
You received this message because you are subscribed to the Google Groups "Querydsl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to querydsl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Frodo S

unread,
Feb 18, 2015, 7:40:27 AM2/18/15
to quer...@googlegroups.com
Hy,

I am seeing the methods innerJoin from the JPAQuery object that accepts a CollectionExpression so maybe with a collection expression coud I get what I want?

Other thing is I dont see any example of how to build a CollectionExpression

Thanks

El martes, 17 de febrero de 2015, 19:52:54 (UTC+1), timowest escribió:
Hi.

I don't think derived tables are supported in JPQL. You will need to use SQL for that.

JPAQuery is restricted by the expressiveness of JPQL.

Br,
Timo

Subash Office

unread,
Oct 14, 2015, 4:17:03 AM10/14/15
to Querydsl
Hi Frodo,

Did you manage to find an answer for your query?

Regards,
Subash

Frodo S

unread,
Oct 14, 2015, 2:43:34 PM10/14/15
to Querydsl on behalf of Subash Office

Yes,  thanks

El 14/10/2015 10:17, "Subash Office via Querydsl" <querydsl+APn2wQclLeaklS1o5eWi3St...@googlegroups.com> escribió:
Hi Frodo,

Did you manage to find an answer for your query?

Regards,
Subash

On Wednesday, February 18, 2015 at 11:40:27 PM UTC+11, Frodo S wrote:
Hy,

I am seeing the methods innerJoin from the JPAQuery object that accepts a CollectionExpression so maybe with a collection expression coud I get what I want?

Other thing is I dont see any example of how to build a CollectionExpression

Thanks

El martes, 17 de febrero de 2015, 19:52:54 (UTC+1), timowest escribió:
Hi.

I don't think derived tables are supported in JPQL. You will need to use SQL for that.

JPAQuery is restricted by the expressiveness of JPQL.

Br,
Timo

On Tue, Feb 17, 2015 at 8:48 PM, Frodo S via Querydsl <querydsl+APn2wQeSzQMzj6aQ-i1j0sm...@googlegroups.com> wrote:
Hy, 

I need to use derived tables with the object JPAQuery. For example in the next case:

JPAQuery q = new JPAQuery(em);
q.from(derivedTable); //derived table
q.innerJoin(derivedTable.id, QUser.user ) // inner join with real table
........


I need derived tables not subquery; already tried it and is really slow. So I need in the from clause to set a derived table and at the same time doing an inner join with other real table connecting both tables or other option would be doing a from operation with a real table and an innerjoin with a derived table but I dont know how to do it in the documentation. An example would be really aprecciated


Thanks a lot

--
You received this message because you are subscribed to the Google Groups "Querydsl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to querydsl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Querydsl" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/querydsl/ddwTSYyUAdg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to querydsl+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages