Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.12
Mapping documents:
tableA.hbm.xml
==========
<hibernate-mapping>
<class name="com.temp.TableA" table="TableA" schema="dbo" catalog="temp">
<id name="pkA" type="string">
<column name="pkA" length="10" />
<generator class="assigned" />
</id>
<property name="colA1" type="string">
<column name="colA1" length="10" />
</property>
<property name="colA2" type="string">
<column name="colA2" length="10" />
</property>
<property name="colA3" type="string">
<column name="colA3" length="10" />
</property>
<set name="tableAblnks" inverse="true">
<key>
<column name="fkA" length="10" not-null="true" />
</key>
<one-to-many class="com.temp.TableAblnk" />
</set>
</class>
</hibernate-mapping>
TableB.hbm.xml
==============
<hibernate-mapping>
<class name="com.temp.TableB" table="TableB" schema="dbo" catalog="temp">
<id name="pkB" type="string">
<column name="pkB" length="10" />
<generator class="assigned" />
</id>
<property name="colB1" type="string">
<column name="colB1" length="10" />
</property>
<property name="colB2" type="string">
<column name="colB2" length="10" />
</property>
<set name="tableAblnks" inverse="true">
<key>
<column name="fkB" length="10" not-null="true" />
</key>
<one-to-many class="com.temp.TableAblnk" />
</set>
</class>
</hibernate-mapping>
TableABLNK.hbm.xml
==============
<hibernate-mapping>
<class name="com.temp.TableAblnk" table="TableABLNK" schema="dbo" catalog="temp">
<composite-id name="id" class="com.temp.TableAblnkId">
<key-property name="fkA" type="string">
<column name="fkA" length="10" />
</key-property>
<key-property name="fkB" type="string">
<column name="fkB" length="10" />
</key-property>
</composite-id>
<many-to-one name="tableB" class="com.temp.TableB" update="false" insert="false" fetch="select">
<column name="fkB" length="10" not-null="true" />
</many-to-one>
<many-to-one name="tableA" class="com.temp.TableA" update="false" insert="false" fetch="select">
<column name="fkA" length="10" not-null="true" />
</many-to-one>
<property name="col1" type="string">
<column name="col1" length="10" />
</property>
<property name="col2" type="string">
<column name="col2" length="10" />
</property>
</class>
</hibernate-mapping>
I have a stored procedure that is as follows on SQLSERVER:
CREATE PROCEDURE dbo.A_B_Select
(
@pkB uniqueidentifier = null
)
AS
SET NOCOUNT ON;SELECT
a.colA1,
a.colA2,
ab.fkA,
ab.fkB,
ab.col1,
ab.col2
FROM
TableABLNK ab
INNER JOIN TableA a on ab.fkA = a.pkA
WHERE (ab.fkB = @pkB) OR (@pkB is null)
ORDER By a.colA1
I am not very clear on how to map my return properties for ab.fkA etc.,
How does the <sql-query> for the above procedure look ?
Thanks