Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.3.0
Name and version of the database you are using: Oracle 10g
Mapped classes
Code:
@MappedSuperclass
public class Model implements Serializable {
private Long id;
@Id
@GeneratedValue
public Long getId() {
return id;
}
}
@Entity
public class Order extends Model {
private Location destination;
@ManyToOne
public Location getDestination() {
return destination;
}
}
@Entity
public class Location extends Model {
private Station station;
@ManyToOne
public Station getStation() {
return station;
}
}
@Entity
public class Station extends Model {
private String name;
private String number;
public String getName() {
return name;
}
public String getNumber() {
return number;
}
}
I am using the Criteria api to generate dynamic queries to return orders. I am having trouble creating a query using the number property of the Station class.
Code:
Criteria crit = session.createCriteria(Order.class);
crit.createAlias("destination.station", "station");
crit.add(Restrictions.like("station.name", someName);
This returns an error, property "destination.station.name" not found on Order.
Is it possible to create an alias for the nested property. I can query using other primitive fields in the Location object this way.
Thanks!