-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: CompositeUserType as part of class id?
PostPosted: Thu Oct 18, 2007 8:26 am 
Newbie

Joined: Wed Jul 05, 2006 9:28 am
Posts: 10
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 18, 2007 1:47 pm 
Newbie

Joined: Wed Jul 05, 2006 9:28 am
Posts: 10
Nevermind...it was a problem with the nullSafeSet method in my custom type class. It wasn't setting the values in the PreparedStatement properly -- once I remedied that, the whole thing works fine.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.