One option would be to do
session.CreateSQLQuery("select parent_id from ChildObject").AddScalar
("parent_id",<Enter your Type>);
This will return an IList<object[]> see:
http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/querysql.html.
Another option is to use a DTO but for only one column probally is
over kill. I think with the Criteria API you can use a result
transformer to just get a IList<T> where t is the type of your column
good luck'
josh
On Nov 10, 4:05 am, Utopico <[EMAIL PROTECTED]> wrote:
> I want to just retreive the foreign key id attirbute for my objects
> retreived from hibernate. I can of course get the child objects
> primary key, but fail to see how to get the foreign key directly.
>
> ChildObject - table A:
> * id
> * name
> * value
> (* parent_id refering to id of table B, but is not normally
> accessible)
>
> ParentObject - table B
> * id
> * address
>
> The reason why I would like to have the foreign key directly is that I
> am going to use it as a filter, and it would be much more efficient
> both to match on the id alone and at the same time it will not be
> necessary to fetch the whole parent object from the database.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---