mysema/querydsl — Issue #82: Entity model using interfaces does not generate Q classes correctly
Author: damienhollis
Created: 2012-01-15 22:27:23+00:00
State: open

Our JPA entity model uses interfaces extensively and it seems that QueryDSL does not handle them correctly.

Here is an example of our model:

@Entity
@Table(name = "USERS")
@org.hibernate.annotations.AccessType("field")
@org.hibernate.annotations.Proxy(proxyClass = User.class)
public class UserImpl extends EntityImpl implements User {

@NaturalId(mutable = true)
@Column(name = "USERNAME", nullable = false)
private String username;

@ManyToOne(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER, targetEntity = PartyImpl.class)
@JoinColumn(name = "PARTY_ID", nullable = false)
private Party party;
}

@javax.persistence.Entity
@Table(name = "PARTY")
@org.hibernate.annotations.AccessType("field")
@org.hibernate.annotations.Proxy(proxyClass = Party.class)
public abstract class PartyImpl extends EntityImpl implements Party {

@Column(name = "NAME", nullable = false)
private String name;
}

Which generates a QUserImpl with the following field:

public final SimplePath party = createSimple("party", Party.class);

However, I believe it should look more like:

this.party = inits.isInitialized("party") ? new QPartyImpl(forProperty("party"), inits.get("party")) : null;

From reading the code it seems that the targetEntity attribute of the ManyToOne annotation is not being inspected. Is this type of model not supported? Or is there something else I need to do to make this work?

Regards,
Damien