Hi guys,
I have two tables -- INSTALL_BUILD_RESULTS and BUILD_RESULTS. IBR has a unique column (non-primary key) called Install_Build_Id and BR has a unique column (non-primary key again) called Build_Id. Both are varchars.
A third table, LINK_BUILD_TO_INSTALL_BUILD is a table simply consisting of the two columns mentioned above, used together as a composite key.
my XMLs for the classes --
BuildResult.hbm.xml --
<hibernate-mapping>
<class name="persistence.BuildResult" table="BUILD_RESULT" schema="dbo" catalog="MSSRELENG_NEWER">
....
<property name="buildId" type="java.lang.String">
<column name="Build_Id" not-null="true" unique="true" />
</property>
....
<set name="installBuildResults" table="LINK_BUILD_TO_INSTALL_BUILD" cascade="all">
<key column="Build_Id" />
<many-to-many column="Install_Build_Id" property-ref="installBuildId" class="persistence.InstallBuildResult" />
</set>
</class>
</hibernate-mapping>
InstallBuildResult.hbm.xml --
<hibernate-mapping>
<class name="persistence.InstallBuildResult" table="INSTALL_BUILD_RESULT" schema="dbo" catalog="MSSRELENG_NEWER">
....
<property name="installBuildId" type="java.lang.String">
<column name="Install_Build_Id" not-null="true" unique="true" />
</property>
....
<set name="buildResults" table="LINK_BUILD_TO_INSTALL_BUILD" cascade="all">
<key column="Install_Build_Id" />
<many-to-many column="Build_Id" property-ref="buildId" class="persistence.BuildResult" />
</set>
</class>
</hibernate-mapping>
and lastly, LinkBuildToInstallBuild.hbm.xml --
<hibernate-mapping>
<class name="persistence.LinkBuildToInstallBuild" table="LINK_BUILD_TO_INSTALL_BUILD" schema="dbo" catalog="MSSRELENG_NEWER">
<composite-id name="id" class="persistence.LinkBuildToInstallBuildId">
<key-many-to-one name="buildResult" class="persistence.BuildResult">
<column name="Build_Id" />
</key-many-to-one>
<key-many-to-one name="installBuildResult" class="persistence.InstallBuildResult">
<column name="Install_Build_Id" />
</key-many-to-one>
</composite-id>
<many-to-one name="buildResult" class="persistence.BuildResult" update="false" insert="false" fetch="select">
<column name="Build_Id" not-null="true" />
</many-to-one>
<many-to-one name="installBuildResult" class="persistence.InstallBuildResult" update="false" insert="false" fetch="select">
<column name="Install_Build_Id" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
Simple test code trying to get some results from the db --
LinkBuildToInstallBuildDAO lbtip = new LinkBuildToInstallBuildDAO();
Session hibernateSession = lbtip.getSession();
Criteria crit = hibernateSession.createCriteria(LinkBuildToInstallBuild.class);
crit.list();
errors out with -- >
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77) org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) org.hibernate.loader.Loader.doList(Loader.java:2223) org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) org.hibernate.loader.Loader.list(Loader.java:2099) org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94) org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569) org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283) beans.vijalTests.main(vijalTests.java:14)
Any help would be much appreciated. Using a simple HQL query, "from LinkBuildToInstallBuild" throws an org.hibernate.exception.DataException as well (via MyEclipse Hibernate HQL).
Regards,
Vijal
|