I'm using Hibernate 3.1.3.
I've got a class called Case, whose only key is caseNumber. I've got a second class called CaseDocument, which has four keys (caseNumber, date, time, seqNbr). I've mapped the date and time fields to a CompositeUserType, so there's only three fields in the mapping:
Code:
<hibernate-mapping>
<class name="net.hctx.jp.hibernate.CaseDocument" table="CCDOCHP">
<composite-id>
<key-property column="OPN4CF" length="12" name="caseNumber" type="string" />
<key-property name="dateIssued" type="net.hctx.jp.hibernate.SynonDateTimeType">
<column name="OPXADT" length="7"/>
<column name="OPBZTM" length="6" />
</key-property>
<key-property column="OPPQNE" length="4" name="documentSequenceNumber" type="integer" />
</composite-id>
<property column="OPN5CF" length="12" name="documentID"
not-null="true" type="string" />
<property column="OPVOCF" length="10" name="userIssuing"
not-null="true" type="string" />
<property column="OPKCTV" length="35" name="primaryPartyName"
not-null="true" type="string" />
</class>
</hibernate-mapping>
CaseDocument is mapped as a one-to-many Set in the Case class:
Code:
<set name="documents" inverse="true">
<key column="OPN4CF" />
<one-to-many class="net.hctx.jp.hibernate.CaseDocument"/>
</set>
If I query CaseDocument by itself, everything works fine. But when I query Case and then attempt to instantiate the Set mapped above, I get an error:
Code:
07:20:41,883 WARN JDBCExceptionReporter:71 - SQL Error: -99999, SQLState: 07001
07:20:41,883 ERROR JDBCExceptionReporter:72 - The number of parameter values set or registered does not match the number of parameters.
07:20:41,899 INFO DefaultLoadEventListener:95 - Error performing load command
org.hibernate.exception.SQLGrammarException: could not load an entity: [net.hctx.jp.hibernate.CaseDocument#component[caseNumber,dateIssued,documentSequenceNumber]{documentSequenceNumber=0, caseNumber=BC11C0112329, dateIssued=Sat Nov 27 08:01:31 CST 2004}]
Here's the last SQL statement that's logged before the error:
Code:
Hibernate:
select
casedocume0_.OPN4CF as OPN1_4_0_,
casedocume0_.OPXADT as OPXADT4_0_,
casedocume0_.OPBZTM as OPBZTM4_0_,
casedocume0_.OPPQNE as OPPQNE4_0_,
casedocume0_.OPN5CF as OPN5_4_0_,
casedocume0_.OPVOCF as OPVOCF4_0_,
casedocume0_.OPKCTV as OPKCTV4_0_
from
JEMSHDP11.CCDOCHP casedocume0_
where
casedocume0_.OPN4CF=?
and casedocume0_.OPXADT=?
and casedocume0_.OPBZTM=?
and casedocume0_.OPPQNE=?
Any idea what might be happening here?
Thanks,
Curt