-->
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.  [ 1 post ] 
Author Message
 Post subject: Joined classes and DataGridView
PostPosted: Mon Feb 04, 2008 7:40 pm 
Newbie

Joined: Mon Feb 04, 2008 7:24 pm
Posts: 6
Hi.

I am testing NHibernate. Following a sample on the web, I created all the classes and mappng files for my application. All is working ok. The problem is that when I bind the results to a DataGridView, the data of the first column, called Orders, appears as (Collection). Here is my mapping file:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">

   <class name="Person, TestHibernate" table="Person">
      <id name="PersonID" column="PersonID" type="Int32" unsaved-value="null">
         <generator class="native" />
      </id>
      <property name="FirstName" column="FirstName" type="String"/>
      <property name="LastName"  column="LastName"  type="String"/>

      <joined-subclass name="Customer, TesteHibernate" table="Customer">
         <key column="PersonID"/>
         <property name="Address" column="Address" type="String"/>
         <property name="City"    column="City"    type="String"/>
         <property name="State"   column="State"   type="String"/>
         <property name="ZipCode" column="ZipCode" type="String"/>

         <set name="Orders">
            <key column="CustomerID"/>
            <one-to-many class="ProductOrder, TestHibernate"/>
         </set>
      </joined-subclass>

      <joined-subclass name="SalesPerson, TestHibernate" table="SalesPerson">
         <key column="PersonID"/>
         <property name="EmployeeNumber" column="EmployeeNumber" type="String"/>

         <set name="AssignedCustomers" table="AssignedCustomers" cascade="save-update">
            <key column="SalesPersonID"/>
            <many-to-many class="Customer, TestHibernate" column="CustomerID"/>
         </set>
      </joined-subclass>
   </class>
</hibernate-mapping>



And that's the class that gets the result from the database:

Code:
   
Public Class Customer
    Inherits Person

    Private _orders As ISet

    Public Overridable Property Orders() As ISet
        Get
            Return _orders
        End Get
        Set(ByVal Value As ISet)
            _orders = Value
        End Set
    End Property

    Public Overridable Property Address() As String
        Get
            Return _address
        End Get
        Set(ByVal Value As String)
            _address = value
        End Set
    End Property

    Public Overridable Property City() As String
        Get
            Return _city
        End Get
        Set(ByVal Value As String)
            _city = value
        End Set
    End Property

    Public Overridable Property State() As String
        Get
            Return _state
        End Get
        Set(ByVal Value As String)
            _state = value
        End Set
    End Property

    Public Overridable Property ZipCode() As String
        Get
            Return _zipCode
        End Get
        Set(ByVal Value As String)
            _zipCode = value
        End Set
    End Property

    Public Shared Function GetCustomers() As List(Of Customer)
        Dim customers As List(Of Customer) = New List(Of Customer)

        ' Open the session
        Dim session As ISession = NHibernateHelper.GetSession()

        ' Load the customers from the database
        session.CreateCriteria(GetType(Customer)).List(customers)

        Return customers
    End Function

End Class


I am binding the DataGridView to the return of the GetCustomers method. How do I correctly show the data from Orders in my DataGridView?

TIA,
rferj[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.