I am getting an odd error when trying to use the @OrderBy annotation. I am getting an exception saying the
updated field doesn't exist, as best I can decipher it anyways. If it matters, I am using postgresql 8.4 for the database. Also, the hibernate version is 3.5.5.
Does anyone see any obvious reasons I would be getting this error message?
Code:
org.hibernate.AnnotationException: property from @OrderBy clause not found: org.crazydays.travian.atlas.db.PlayerName.updated
org.hibernate.cfg.annotations.CollectionBinder.buildOrderByClauseFromHql(CollectionBinder.java:946)
org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:710)
org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:666)
org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:619)
org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66)
org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1221)
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:383)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1377)
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
...
Code:
CREATE TABLE player (
id NUMERIC NOT NULL,
updated DATE NOT NULL,
tribe NUMERIC NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE player_name (
id NUMERIC NOT NULL,
updated DATE NOT NULL,
name VARCHAR(64) NOT NULL,
PRIMARY KEY (id, updated)
);
Code:
@Entity
@Table(name = "player")
public class Player
implements Serializable
{
/** serial version uid */
public static final long serialVersionUID = "$Id$".hashCode();
/** id */
@Id
protected int id;
/** updated */
protected Date updated;
/** tribe */
protected int tribe;
/** names */
@OneToMany
@JoinColumn(name = "id")
@OrderBy(value = "updated DESC")
protected List<PlayerName> names;
... appropriate getters and setters ...
... equals and hashCode implementation ...
}
Code:
@Entity
@Table(name = "player_name")
public class PlayerName
implements Serializable
{
/** serial version uid */
public static final long serialVersionUID = "$Id$".hashCode();
/** id */
@Id
protected int id;
/** updated */
@Id
protected Date updated;
/** name */
protected String name;
... appropriate getters and setters ...
... equals and hashCode implementation ...
}