Hi,
I have the follwing classes:
Contact.java:
@Entity
@PersistenceContext(unitName = "processEntities")
@Table(name = "contact")
public class Contact extends BaseEntity {
private static final long serialVersionUID = 1L;
private String street1;
private String street2;
private String zip;
private String city;
private String emailAddress;
private String phone;
...
Person.java
Entity
@Table(name = "person")
@Inheritance(strategy = InheritanceType.JOINED)
@PersistenceContext(unitName = "processEntities")
public class Person extends BaseEntity {
@OneToOne(cascade={CascadeType.ALL})
private Contact contact;
private static final long serialVersionUID = 1L;
@Column(unique=true)
private String thmUid;
private String academicTitle;
private String lastName;
private String firstName;
private Gender gender;
...
Instructor.java
@Entity
@Table(name = "instructor")
@PersistenceContext(unitName = "processEntities")
public class Instructor extends Person {
...
}
ThesisSecondInstructor.java
@Entity
@Table(name = "thesissecondinstructor")
@PersistenceContext(unitName = "processEntities")
public class ThesisSecondInstructor extends Instructor {
...
}
Now I want to get the the thesisSecondInstrutor by his emailaddress, which is saved in Contact.
I tried the following
Query q = entityManager.createQuery("SELECT s FROM ThesisSecondInstructor s WHERE s.contact.emailaddress = :emailAddress ");
q.setParameter("emailAddress",emailAddress);
but I get
Caused by: org.hibernate.QueryException: could not resolve property: emailaddress of: de.thm.mnd.ofv.persistence.entities.Contact
Has anyone ideas how to solve that?
Thanks a lot,
Nicole