-->
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.  [ 6 posts ] 
Author Message
 Post subject: path expression ends in a composite value
PostPosted: Fri Mar 31, 2006 9:03 am 
Newbie

Joined: Fri Mar 31, 2006 8:49 am
Posts: 4
Location: NL
I have problems querying a table that contains a composite index.
I simplified it to:

List results = find("SELECT count(rt) FROM RankedTeam rt");

this statement throws an Exception:

net.sf.hibernate.QueryException: path expression ends in a composite value: rankedteam0_ [SELECT count(rt) FROM ndc.data.RankedTeam rt]'

There is no problem with the same query for a table with no <composite-id>. The hbm is shown below. What am I doing wrong????

RankedTeam.hbm:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="ndc.data">
   <class name="RankedTeam" table="wk_teamposition">
      <cache usage="read-write"/>
      <composite-id class="RankedTeamPK" name="compositeId">
         <key-property
            column="team_id"
            name="teamId"
            type="integer"
          />
         <key-property
            column="table_id"
            name="tableId"
            type="integer"
          />
         <key-property
            column="subleague_id"
            name="subleagueId"
            type="integer"
          />
      </composite-id>
      <property
         column="teamscore_totalscore"
         length="11"
         name="overallScore"
         not-null="true"
         type="int"
       />
      <property
         column="teamposition_previousposition"
         length="10"
         name="previousPosition"
         not-null="true"
         type="int"
       />
      <property
         column="teamscore_sumscore"
         length="11"
         name="score"
         not-null="true"
         type="int"
       />
      <property
         column="teamposition_currentposition"
         length="10"
         name="position"
         not-null="true"
         type="int"
       />
      <property
         column="team_name"
         length="50"
         name="teamName"
         not-null="true"
         type="string"
       />
      <property
         column="teamposition_totalposition"
         length="10"
         name="overallPosition"
         not-null="true"
         type="int"
       />
      <property
         column="coach_id"
         length="10"
         name="coachId"
         not-null="false"
         type="int"
       />

      <property
         column="teamscore_avgscore"
         length="11"
         name="averageScore"
         not-null="true"
         type="double"
       />
      <property
         column="coach_coachname"
         length="50"
         name="coachName"
         not-null="true"
         type="string"
       />
      <property
         column="teamscore_avgteamvalue"
         length="11"
         name="averageTeamValue"
         not-null="true"
         type="double"
       />
      <property
         column="teamscore_sumteamvalue"
         length="11"
         name="teamValue"
         not-null="true"
         type="int"
       />
       <property
            column="subleague_id"
            name="subleagueId"
            type="int"
            insert="false"
            update="false"
         />
       <property
            column="coach_city"
            name="city"
            type="string"
            not-null="true"
            length="50"
         />
      <property
         column="team_active"
         name="active"
         type="boolean"
         not-null="true"
      />
      
      <many-to-one name="ranking" class="Ranking" column="table_id" insert="false" update="false"/>
   </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 2:47 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
there's something on this page
http://www.hibernate.org/hib_docs/refer ... ryhql.html

if you do a page search for ends in a you will get to the description describing the cause for that error, but I do not see why you are getting that error.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 2:56 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
I don't konw how your collections are set up, but it look as though this part "ndc.data.RankedTeam" is the cause of the problem. is one of those a composite key?

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 02, 2006 11:33 am 
Newbie

Joined: Fri Mar 31, 2006 8:49 am
Posts: 4
Location: NL
kochcp wrote :
>It look as though this part "ndc.data.RankedTeam" is the cause of the >problem

my "ndc.data.RankedTeam" class is generated by the Hibernate synchronizer. As you can see in the .hbm file, the table contains a composite id.

>there's something on this page
>http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html

yes, I already googled that page before posting here, but it didn't help me.
the page describes an other situation.

I'm still puzzled.....


Top
 Profile  
 
 Post subject: Similar problem solved
PostPosted: Mon Dec 29, 2008 9:07 pm 
Newbie

Joined: Mon Dec 29, 2008 7:40 pm
Posts: 6
Location: France
Hopefully your not still puzzled nearly 3 years on!

In your case I'd try...

Code:
SELECT count(rt.Id.SomeObj) FROM RankedTeam rt

as I'm guessing you have a RankedTeamPK class.

While trying to "group by" the "count" of total "votes" for each "person" I had the same QueryException with this incorrect query...

Code:
select person from Person person
left join person.VoteSet votes
group by person order by count(votes) desc

it worked when I modified the "count" part...

Code:
select person from Person person
left join person.VoteSet votes
group by person order by count(votes.Id.Person) desc

My mapping files and model classes are generated by Hibernate Synchronizer so in Person.hbm I have...

Code:
<set inverse="true" name="VoteSet">
    <key column="personId" />
    <one-to-many class="Vote" />
</set>

and in Vote.hbm I have...

Code:
<composite-id class="VotePK" name="Id">
    <key-many-to-one
        class="Person"
        column="personId"
        name="Person"
    />
    <key-many-to-one
        class="User"
        column="userId"
        name="User"
    />
</composite-id>

Because of the VotePK class it's also annoying having to do something like this in a JSP...

Code:
<c:forEach var="vote" items="${person.voteSet}" ...
${vote.id.person.id}
${vote.id.user.id}

so I add (in this case to Vote.java)...

Code:
public Long getPersonId(){
    return getId().getPerson().getId();
}
   
public Long getUserId(){
    return getId().getUser().getId();
}

so I can do...

Code:
<c:forEach var="vote" items="${person.voteSet}" ...
${vote.personId}
${vote.userId}

which feels more natural.

Anyway, hope this helps someone in the future to solve a net.sf.hibernate.QueryException: path expression ends in a composite value:

;o)


Last edited by DJDaveMark on Sat Feb 28, 2009 12:41 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Similar problem solved
PostPosted: Mon Dec 29, 2008 9:08 pm 
Newbie

Joined: Mon Dec 29, 2008 7:40 pm
Posts: 6
Location: France
Error: Please delete Mr Moderator


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.