-->
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.  [ 3 posts ] 
Author Message
 Post subject: One field to two columns using UserType
PostPosted: Wed Oct 10, 2007 3:01 pm 
Newbie

Joined: Wed Jul 05, 2006 9:28 am
Posts: 10
I've got a DB table with a four-column key:

CaseNumber
DateIssued
TimeIssued
SequenceNbr

I'd like to combine the DateIssued and TimeIssued columns into a single field in my Java class using a UserType.

Here's the mapping from my hbm.xml file for that class:

Code:
<hibernate-mapping>
   <class name="net.hctx.jp.hibernate.CaseDocumentHistory" 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="short" />
      </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>


When I attempt to load this class, I get the following error:

Code:
org.hibernate.MappingException: identifier mapping has wrong number of columns: net.hctx.jp.hibernate.CaseDocumentHistory type: component[caseNumber,dateIssued,documentSequenceNumber]
   org.hibernate.mapping.RootClass.validate(RootClass.java:194)
   org.hibernate.cfg.Configuration.validate(Configuration.java:984)
   org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
   net.hctx.jp.hibernate.util.HibernateUtil.createSessionFactory(HibernateUtil.java:34)
   org.apache.jsp.CaseInfo.CaseInfo_jsp._jspService(CaseInfo_jsp.java:104)
   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


Any idea where to begin on this one?

Thanks,
Curt


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 11, 2007 12:08 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Does SynonDateTimeType correctly implement CompositeUserType?

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 11, 2007 11:10 am 
Newbie

Joined: Wed Jul 05, 2006 9:28 am
Posts: 10
Yikes! No, it doesn't. It implements UserType.

After reading up on CompositeUserType and tinkering with it, that seems to have solved the problem.

The tutorial suggests implementing either UserType or CompositeUserType, but doesn't say when to use which. I've done UserType before, so that's where I began.

Thanks for your help, tenwit!

Curt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.