-->
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: One-To-Many and GridView
PostPosted: Tue Mar 21, 2006 2:52 am 
Newbie

Joined: Mon Jan 09, 2006 12:27 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 1.02

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: SQL Server Express 2005

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Hi, I'm a complete newbie to NHibernate and I have this question regarding binding a oneToMany Relationship to a GridView or Repeater for that matter.

I use the standard NorthWind Database. I'm testing using the "Customers" and "Orders" table. What I want is a list of "CompanyName" from the "Customers" Table and the "OrderDate" of the companies from "Orders" table.

Normally, I would execute a sql like so

"SELECT dbo.Customers.CompanyName, dbo.Orders.OrderDate
FROM dbo.Customers LEFT OUTER JOIN
dbo.Orders ON dbo.Customers.CustomerID = dbo.Orders.CustomerID"

and bind the "CompanyName" and "OrderDate" as columns to the GridView or Repeater.

I understand how to get a List of Orderd by CustomerID, but how do you return a List of "Customers" and "Orders" so you can bind to a GridView?

I know it's a basic concept, I just have a hard time finding an example.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 21, 2006 3:13 am 
Newbie

Joined: Mon Jan 09, 2006 12:27 am
Posts: 8
Hm.. Now I see you can use

ISession.Find() which return an IList of object using HQL. Say this HQL query is something like

"select Customer.CompanyName, Orders.OrderDate
from TestApp.Customers as Customers,
TestApp.Orders as Orders
Where
Customer.CustomerID = Orders.CustomerID"

(just my guess at the minute, havne't run it yet)

Exactly what is this object returned and how do I perform this HQL query such that when I bind to GridView, I know which column is "CompanyName" and which column is "OrderDate".

Confused and don't know how to go any further than this.

Thanks.


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.