Re: JPASQLQuery uses class name instead of @Table(name="") in generated sql

681 views
Skip to first unread message

Timo Westkämper

unread,
Sep 5, 2014, 2:32:17 PM9/5/14
to Querydsl on behalf of John Tims
Hi John.

On Fri, Sep 5, 2014 at 8:52 PM, John Tims via Querydsl <querydsl+noreply-APn2wQfED65x1vI...@googlegroups.com> wrote:
Hi,

I'm generating Q classes from JPA entities using the maven JPAAnnotationProcessor. Normally, I use JPAQuery and everything works but I needed to UNION two queries so I tried to use JPASQLQuery.

Entities with names that map directly to its corresponding table work fine but if it's different then the "table is not found".

Example:

@Table(name="user")
class User

works fine but

@Table(name="other_user")
class User

will still try to generate SQL that refers to a table named User and fail.

Is there a way to override which table is used?

Entity based generated types are only supported in the projection/select part of the query. If you need other table names beside the simple class name of the entity you will need to generate also the types for the SQL schema as suggested here http://www.querydsl.com/static/querydsl/3.4.3/reference/html/ch02.html#d0e395

Feel free to create an issue for taking @Table/@Column annotations into account in JPA native queries.

Br,
Timo

 


- John

--
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.

John Tims

unread,
Sep 5, 2014, 2:54:09 PM9/5/14
to quer...@googlegroups.com
Thanks for the fast reply, Timo!

I've created an issue: https://github.com/querydsl/querydsl/issues/926

Obviously it wouldn't make sense for SQLQuery but I think @Table and @Column should be taken into account with JPASQLQuery.

- John


On Friday, September 5, 2014 2:32:17 PM UTC-4, timowest wrote:
Hi John.
Reply all
Reply to author
Forward
0 new messages