Hello,
I have a Foreign Key that is a Primary Key. I did:
Code:
@Embeddable
public class PersonPk implements Serializable {
@ManyToOne(optional=false, cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="psId")
private Person person;
// gets and sets
}
My user table that uses PersonPk
Code:
@Entity @Table
public class User {
@Id
private PersonPk pk = new PersonPk();
// gets and sets
}
Now I want to find users with the name John... I'm trying this:
Code:
Criteria c = session.createCriteria(User.class);
c.setFetchMode("pk.person", FetchMode.JOIN);
c.createAlias("pk.person", "person");
c.add(Expression.ilike("person.name", "John"));
But doesn't works.. JOIN was not made. How can I do? I'm not using inheritance because I need share person's id, with another tables.