For example, I have two entities: Employee and Address. Of these enitities, Employee has a foreign key AddressID references the ID column on Address. In the Java domain obje
Having similar trouble... @ChssPly76 answer works fine, but just found solution if foreign key is not part of Id in parent table - you must modify annotation by adding "referencedColumnName":
@ManyToOne
@JoinColumn(name="address_id", referencedColumnName="addrUniqueFieldName")
private Address address;
and then you can create criteria:
criteria.add(restriction.eq("address.addrUniqueFieldName", 123);