-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problem Binding NHibernate collections to DataGridView
PostPosted: Fri Oct 21, 2005 12:19 am 
hi,
Am getting some problem when binding an IList returned by session.CreateQuery() method. issue is, when i do a theta style join on two tables, (ie; tables which doesn't have direct relationships eg: "from Authors a,Publishers p where a.City = p.City") its returning a List with Two Dimensions of Authors and Publishers . ie; one row contains two objects . so am not able to bind it with grid. is there any mapping options or anyother ways to get it as one object?

is there any options to specify an alias for a column in a HQL Query? am getting errors if i use "as" keyword to specify aliases for columns.

Please help
Thanks in advance
Sarin


Top
  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 2:55 am 
Newbie

Joined: Tue Oct 11, 2005 10:40 am
Posts: 4
Hi Sarin,
you probably have to specify wich entity you want with the select statement eg:
Code:
select a from Author a, Publisher p where a.City = p.City


HTH
Massimo


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 4:06 am 
That approach i tried alerady. Select a.Auth_id,p.Pub_id from Authors a,Publishers p where a.City=p.City. This again will give me two objects in one row. Any other solutions???

Rgds
Sarin


Top
  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 6:13 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Hey Sarin,

Just to clarify, what data are you specifically trying to retrieve from the query? Are you after a single object and just introducing the join so you can perform the query, or are you specifically trying to retrieve data from more than one object?

If you execute a query that returns anything other than a single class (SELECT e FROM entity e) or a single value (SELECT e.property FROM entity e) you will get the behavior you are experiencing.

If you're only using your join so you can use the joined object in a criteria statement in your WHERE clause then you can indicate that you only want one of the object types specified by providing it in the SELECT clause (SELECT e FROM entity e INNER JOIN otherentity o WHERE e.property = 'abc' AND o.property = 'xyz'). In this case you will only get back a list of the entity objects that meet the criteria.

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 10:39 am 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
You can use the import mapping (http://nhibernate.sourceforge.net/nh-docs/html/mapping.html#mapping-declaration-import) to allow selecting an aggregate object. See the last example at http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html#queryhql-select for an example of that select statement.


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