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" but no
PostPosted: Wed Jun 18, 2008 10:30 am 
Newbie

Joined: Wed May 21, 2008 9:54 am
Posts: 8
Edit: topic title got concatenated, it should be "path expression ends in a composite value" but no composite key


Some mapping:

<class name="MyProject.Child, MyProject" table="Child">
<id name="ID" access="property" column="ID" type="Int64" unsaved-value="0">
<generator class="hilo">
<param name="max_lo">9</param>
</generator>
</id>
......
.......
</class>

query:

select a.ID, a.Name, a.OpenDate, count(*), sum(c.Amount)) from Parent a inner join a.Child as b, Granchild c
where c.ChildID = b.ID and b.Parent = ?
group by a.ID, a.Name, a.OpenDate

this fails with a query exception "Path expression ends in a composite value".
I think its the "where c.ChildID = b.ID" that causes it, because if I change the query to b.Id it complains about not being able to resolve Id, which I would expect.

None of the objects have a composite key, in fact they are all identical to the above mapping, so why does it complain about a composite value ? how is that even possible ? I can't find anything that relates to this.

I'm trying to achieve this:
select a.ID, a.NAME, a.OPENDATE, count(c.ID) 'TOTAL COUNT', sum(c.AMOUNT) 'TOTAL AMOUNT'
from PARENT a join CHILD b on a.CHILD = b.ID
join GRANCHILD c on b.ID = c.CHILDID
where b.PARENT = ?
group by a.ID, a.NAME, a.OPENDATE


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 8:18 am 
Newbie

Joined: Wed May 21, 2008 9:54 am
Posts: 8
Further Info: I found some references to ID being a reserved word in HQL, I changed all ID properties to be UID but the query still causes the same error.

Can I supply any more information to progress with this ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 10:18 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
You get this exception, because the result of that query isn't a type NHibernate knows. You can use AddScalar(...) to retrieve the raw data without fetching them into objects. Or you can use a ResultTransformer (AliasToBean) to fetch the data into custom typed objects, where the properties have the same names as the retrieved columns.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 11:01 am 
Newbie

Joined: Wed May 21, 2008 9:54 am
Posts: 8
Thanks for the reply.

This gets complicated, because I have to use Castle on top of NHibernate, the resulting type of the query is registered, but for whatever reason isn't being passed to NHibernate.

I'll have to shift my focus to what Castle is doing to figure it out.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 2:14 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
You could try to use a query like that:

Code:
select new MyType(a.ID, a.Name, a.OpenDate, count(*), sum(c.Amount)) from ...


where MyType is your class which has a constructor that takes the columns in this query as parameters.

Perhaps this way works...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 20, 2008 3:06 am 
Newbie

Joined: Wed May 21, 2008 9:54 am
Posts: 8
Typhos, thats exactly what I'm doing, I need to find out why AR hasn't mapped MyType.


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.