-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: @OrderBy: property from @OrderBy clause not found
PostPosted: Thu Sep 09, 2010 4:34 pm 
Newbie

Joined: Thu Sep 09, 2010 3:30 pm
Posts: 2
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 ...
}


Top
 Profile  
 
 Post subject: Re: @OrderBy: property from @OrderBy clause not found
PostPosted: Sat Sep 11, 2010 9:12 am 
Newbie

Joined: Thu Sep 09, 2010 3:30 pm
Posts: 2
I found the solution. First was, I was using the java.persistance.OrderBy instead of the org.hibernate.annotations.OrderBy. And the parameter for the Hibernate OrderBy is clause, not value.

Code:
import org.hibernate.annotations.OrderBy;

... class declaration ...

    /** names */
    @OneToMany
    @JoinColumn(name = "id")
    @OrderBy(clause = "updated DESC")
    protected List<PlayerName> names;


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.