I could really use some help with this as it is taking too long todo
something I thought was relatively simple.
I am unable to get data from a legacy table with a composite key. The
mapping, class and test query are below. I have marked the class
'Serializable' and overridden Equals and GetHashCode (although there were no
compile error or exceptions when I did not do this). When the sample query
executes there is no sql (or exception) generated.
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
schema="HCOMS_USER"
assembly="SIS.Model"
namespace="SIS.Model">
<class name="CityRef" table="CORE_CITY_TOWN">
<composite-id>
<key-property name="CityName" column="CITY_TOWN_NAME_TXT"
type="string"/>
<key-property name="ProvinceCD" column="PROVINCE_CD" type="string"/>
</composite-id>
</class>
</hibernate-mapping>
=================================================================
<Serializable()> _
Public Class CityRef
Implements IAggregateRoot
Private _cityName As String
Private _provinceCd As String
Public Sub New()
End Sub
Public Sub New(ByVal CityName As String, ByVal ProvinceCd As String)
_cityName = CityName
_provinceCd = ProvinceCd
End Sub
Public Overridable Property CityName() As String
Get
Return _cityName
End Get
Set(ByVal value As String)
_cityName = value
End Set
End Property
Public Overridable Property ProvinceCD() As String
Get
Return _provinceCd
End Get
Set(ByVal value As String)
_provinceCd = value
End Set
End Property
Public Overrides Function Equals(ByVal obj As Object) As Boolean
If obj Is Nothing Then
Return False
End If
Dim t As CityRef = CType(obj, CityRef)
If t Is Nothing Then
Return False
End If
If (Me._cityName = t._cityName AndAlso Me._provinceCd =
t._provinceCd) Then
Return True
Else
Return False
End If
End Function
Public Overrides Function GetHashCode() As Integer
Return _cityName.GetHashCode Xor _provinceCd.GetHashCode
End Function
End Class
==============================================================
Dim myList As IList(Of CityRef) = _
SessionManager.GetCurrentSession _
.CreateCriteria(GetType(CityRef)).List(Of
CityRef)()
John Davidson
--
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.