I have an entity containing an embeddable like this:
@Entity
@Table(name = "region_name")
public class RegionName implements KeyedValue{
private Integer id;
private RegionKey regionKey;
private String name;
@Id
@Column(name = "id", nullable = false, insertable = true, updatable = true)
public Integer getId() {
return id;
}
@Embedded
public RegionKey getRegionKey() {
return regionKey;
}
@Basic
@Column(name = "name", nullable = false, insertable = true, updatable = true, length = 100)
public String getName() {
return name;
}
...
}
and the class RegionKey like this:
@Embeddable
public class RegionKey extends CountryKey {
protected Integer regionId;
...
@Basic
@Column(name = "region_id", nullable = true, insertable = true, updatable = true)
public Integer getRegionId() {
return regionId;
}
...
}
and the CountryKey class like this:
@Embeddable
public class CountryKey implements Key {
private Integer countryId;
...
@Basic
@Column(name = "country_id", nullable = false, insertable = true, updatable = true)
public Integer getCountryId() {
return countryId;
}
...
}
All of the Q-classes are well generated. But If I try to find all RegionNames for a given country the I create an hibernate query like this:
public Stream<RegionName> allRegionsForCountry(CountryKey countryKey) {
QRegionName qRegionName = QRegionName.regionName;
HibernateQuery hq = new HibernateQuery(getSessionFactory().getCurrentSession());
return hq.from(qRegionName).where(
qRegionName.regionKey.countryId.eq(countryKey.getCountryId())).list(qRegionName).stream();
}
and get the following error :
org.hibernate.QueryException: could not resolve property: regionKey.countryId of: de.lstrobel.js_eval.geo.model.RegionName [select regionName
from de.lstrobel.js_eval.geo.model.RegionName regionName
where regionName.regionKey.countryId = ?1]
Can anybody give me a hint how to get rid of this?
Thanx
Lutz