Take @Table/@Column annotations into account in JPA native queries #926

Closed
johnktims opened this Issue Sep 5, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@johnktims
Member

johnktims commented Sep 5, 2014

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.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Sep 30, 2014

Member

Released in 3.5.0

Member

timowest commented Sep 30, 2014

Released in 3.5.0

@schragmanuel

This comment has been minimized.

Show comment
Hide comment
@schragmanuel

schragmanuel Nov 17, 2015

I'm seeing a problem related to this in Version 3.6.9:

My entity has a many to one relation to another entity:

@javax.persistence.ManyToOne(targetEntity = ch.ims.suisdata.core.model.address.Address.class)
@javax.persistence.JoinColumn(name = "NADR_ID", nullable = true, updatable = false, insertable = false)
private Address address;

When i try to do a join, the on part is not mapped to the foreign key column:

new JPASQLQuery(em, new OracleTemplates()).from(qEntity).leftJoin(qAddress).on(qEntity.address.eq(qAddress.));

This results in the query:

select ... left join ADRESSEN address on errorView.address = address

but it should be

select ... left join ADRESSEN address on errorView.NADR_ID = address.NID

I'm not sure if I do something wrong in the syntax of the query or if it's a QueryDsl issue.

I'm seeing a problem related to this in Version 3.6.9:

My entity has a many to one relation to another entity:

@javax.persistence.ManyToOne(targetEntity = ch.ims.suisdata.core.model.address.Address.class)
@javax.persistence.JoinColumn(name = "NADR_ID", nullable = true, updatable = false, insertable = false)
private Address address;

When i try to do a join, the on part is not mapped to the foreign key column:

new JPASQLQuery(em, new OracleTemplates()).from(qEntity).leftJoin(qAddress).on(qEntity.address.eq(qAddress.));

This results in the query:

select ... left join ADRESSEN address on errorView.address = address

but it should be

select ... left join ADRESSEN address on errorView.NADR_ID = address.NID

I'm not sure if I do something wrong in the syntax of the query or if it's a QueryDsl issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment