-->
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: Query problem ???
PostPosted: Tue Dec 30, 2003 10:45 pm 
Regular
Regular

Joined: Tue Nov 04, 2003 12:37 pm
Posts: 57
Hello,

How can I define q query in the following condition?

- I want to get a LIST of the Player with the descending order by the
SUM(Team.score) ???

The following is my beans definition.

Bets regards,
Eric



Code:
Player.java
-------

public void setTeams(Set teams) {
      this.teams = teams;
   }
   
   
   /**
    * @hibernate.set
    *    lazy="true"
    *    table="team_player"
    *    order-by="teamId"
    *
    * @hibernate.collection-key
    *    column="playerId"
    *
    * @hibernate.collection-many-to-many
    *    class="test.model.Team"
    *    column="teamId"
    *
    *
    */
   public Set getTeams() {
      return teams;
   }



Code:
Team.java
-------------

/**
    * @hibernate.property
    *    not-null="true"
    */
   public int getScore() {
      return score;
   }
   
   public void setScore(int score) {
      this.score = score;
   }

   public void setPlayers(Set players) {
      this.players = players;
   }
   
    /**
    * @hibernate.set
    *    lazy="true"
    *    table="team_player"
    *    order-by="teamId"
    *
    * @hibernate.collection-key
    *    column="teamId"
    *
    * @hibernate.collection-many-to-many
    *    class="test.model.Player"
    *    column="playerId"
    *
    *
    */
   public Set getPlayers() {
      return players;
   }



Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 31, 2003 7:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I would try

Code:
select players from Players as players join players.teams as teams order by sum(teams.score)

Untested though ...


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.