I am using Hibernate3 running on JBoss accessing SQLServer 2005.
1. I have the following setup in log4j.xml
<category name="org.hibernate.type">
<priority value="INFO"/>
</category>
but it is still not telling me the value of the ? in my SQL.
2. I am having problems setting up a set mapping.
Table1 - Division:
divisionId integer identity not null, (key) oldDivisionCode String not null
Table2 - Community:
communityId integer identity not null, (key) oldCommunityCode String not null, oldDivisionCode String not null
Division.hbm.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.ve.data.hibernate.mappings.Division" table="Division" schema="dbo" catalog="VendorExtranet">
<id name="id" type="java.lang.Integer" column="divisionId" >
<generator class="identity" />
</id>
<property name="divisionCode" type="java.lang.String">
<column name="oldDivisionCode" length="10" not-null="true" />
</property>
<set name="communities" inverse="true">
<key column="oldDivisionCode" not-null="true" />
<one-to-many class="com.ve.data.hibernate.mappings.Community" />
</set>
</class>
</hibernate-mapping>
Community.hbm.xml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.ve.data.hibernate.mappings.Community" table="Community" schema="dbo" catalog="VendorExtranet">
<id name="id" type="java.lang.Integer">
<column name="communityId" />
<generator class="identity" />
</id>
<property name="projectCode" type="java.lang.String">
<column name="oldProjectCode" length="12" not-null="true" />
</property>
<property name="divisionCode" type="java.lang.String">
<column name="oldDivisionCode" length="3" />
</property>
<many-to-one name="division" class="com.ve.data.hibernate.mappings.Division" unique="true" insert="false" update="false">
<column name="oldDivisionCode" not-null="true" />
</many-to-one>
</class>
</hibernate-mapping>
The communities set is not working properly it needs to join Division and Community on oldDivisionCode,
but I think it seems to be joining oldDivisionCode to (divisionId or communityId).
I can't quite tell because I can't see the result of the ? in the query.
Below is the query result that I am getting when I call
Division division;
//division found by Id
division.getCommunities();
20:48:04,587 INFO [STDOUT] Hibernate: select communitie0_.jdeDivisionCode as jdeDivis3_1_, communitie0_.communityId as communit1_1_, communitie0_.communityId as communit1_0_0_, communitie0_.jdeProjectCode as jdeProje2_0_0_, communitie0_.jdeDivisionCode as jdeDivis3_0_0_
from VendorExtranet.dbo.Community communitie0_
where communitie0_.jdeDivisionCode=?
Any help would be greatly appreciated.
Thanks,
pcable
|