I've reached dead end with this. I keep getting:
Exception Description: Syntax error parsing [SELECT a FROM UserEntity u JOIN u.addresses a WHERE u.email =: email].
[52, 69] The expression is not a valid conditional expression.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1585)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
My entities:
@Getter
@Setter
@EqualsAndHashCode
@Entity
@Table(name = "ADDRESS", schema = "Test")
public class AddressEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;
@Basic
@Column(name = "address_name")
private String addressName;
@Basic
@Column(name = "address_content")
private String addressContent;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private UserEntity user;
@Getter
@Setter
@EqualsAndHashCode
@Entity
@Table(name = "USER", schema = "Test")
public class UserEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private int id;
@Basic
@Column(name = "email")
private String email;
@Basic
@Column(name = "password")
private String password;
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
private List<AddressEntity> addresses;
}
My DAO:
Query query = em.createQuery("SELECT a FROM UserEntity u JOIN u.addresses a WHERE u.email =: email");
query.setParameter("email", email);
return query.getResultList();
I have no idea what's wrong. I've already tried it with allArgsConstructor and also tried to fetch it from the AddressEntity.
I'm using TomEE plume 7.0.3
Thanks in advance!