-->
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.  [ 10 posts ] 
Author Message
 Post subject: Can an object in a set contain another set?
PostPosted: Mon Aug 15, 2005 10:28 am 
Newbie

Joined: Mon Aug 15, 2005 10:04 am
Posts: 6
I have to represent an insurance claim. A claim contains multiple benefits. A benefit can have many changes which i need to keep track of. The Claim class has a Set of Benefit objects, each Benefit objects has a Set containing BenefitChanges. When I try to validate the xml it says "Unexpected element <set>. Can a set not contain another set?

Hibernate version: 3.0.5

Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.iso.wc.fst.valueobjects.reports">
<class name="Claim" table="ISO25.WCV00422">
<composite-id name="claimReportKey" class="ClaimReportKey">
<key-property name="customerId" column="N_CO_GRP" type="string"/>
<key-property name="insdRptNum" column="N_INSRD_RPT" type="string"/>
<key-property name="jurisCd" column="C_JRSD_ST" type="string"/>
<key-property name="clmAdminFein" column="I_CLMADM_FEIN" type="string"/>
<key-property name="rptType" column="C_RPT_TYP" type="string"/>
<key-property name="mtc" column="C_MTC" type="string"/>
<key-property name="mtcDt" column="D_MTC" type="date"/>
<key-property name="rptTimestamp" column="H_RPT_TS" type="timestamp"/>
<key-property name="tempFlag" column="F_TMP" type="string"/>
</composite-id>
<set name="benefits" table="ISO25.WCV00429">
<key>
<column name="N_CO_GRP" sql-type="integer"/>
<column name="N_INSRD_RPT" sql-type="string"/>
<column name="C_JRSD_ST" sql-type="string"/>
<column name="I_CLMADM_FEIN" sql-type="string"/>
<column name="C_RPT_TYP" sql-type="string"/>
<column name="C_MTC" sql-type="string"/>
<column name="D_MTC" sql-type="date"/>
<column name="H_RPT_TS" sql-type="timestamp"/>
<column name="F_TMP" sql-type="string"/>
</key>
<composite-element class="Benefit">
<property name="cd" column="C_BENE_TYP" type="string"/>
<property name="includedInTrnsFlag" column="F_INCL_TRNS" type="string"/>
<property name="tempDeleteFlag" column="F_TMP_DEL" type="string"/>
<property name="benEvalStatus" column="C_BENE_EVAL_STUS" type="string"/>
<property name="benStatus" column="C_BENE_STUS" type="string"/>
<property name="seqNum" column="N_BENE_TYP_SEQ" type="string"/>
<property name="benLvlMTC" column="C_BENE_LVL_MTC" type="string"/>
<property name="grossWklyAmt" column="A_GRS_WKLY" type="string"/>
<property name="grossWklyAmtEffDt" column="D_GRS_WKLY_AMT_EFF" type="string"/>
<property name="netWklyAmt" column="A_NET_WKLY" type="string"/>
<property name="netWklyAmtEffDt" column="D_NET_WKLY_AMT_EFF" type="string"/>
<property name="benPeriodStartDt" column="D_BENE_PER_STRT" type="string"/>
<property name="benPeriodThroughDt" column="D_BENE_PER_THRU" type="string"/>
<property name="ClmWks" column="N_BENE_TYP_CLM_WKS" type="string"/>
<property name="clmDays" column="N_BENE_TYP_CLM_DAY" type="string"/>
<property name="amtPaid" column="A_BENE_TYP_AMT_PD" type="float"/>
<property name="paymentIssueDt" column="D_PMT_ISU" type="string"/>
<property name="partialSuspCd" column="C_PRTL_SUSPN" type="string"/>
<property name="denialTxCount" column="N_DNL_TRNS_CNT" type="integer"/>
<set name="benefitChanges" table="ISO25.WCV00430">
<key>
<column name="N_CO_GRP" sql-type="integer"/>
<column name="N_INSRD_RPT" sql-type="string"/>
<column name="C_JRSD_ST" sql-type="string"/>
<column name="I_CLMADM_FEIN" sql-type="string"/>
<column name="C_RPT_TYP" sql-type="string"/>
<column name="C_MTC" sql-type="string"/>
<column name="D_MTC" sql-type="date"/>
<column name="H_RPT_TS" sql-type="timestamp"/>
<column name="F_TMP" sql-type="string"/>
<column name="C_BENE_TYP" sql-type="string"/>
</key>
<composite-element class="BenefitChange">
<property name="benTypeCd" column="C_BENE_TYP" type="string"/>
<property name="cd" column="C_BENE_ACR" type="string"/>
<property name="includedInTrnsFlag" column="F_INCL_TRNS" type="string"/>
<property name="tempDeleteFlag" column="F_TMP_DEL" type="string"/>
<property name="ind" column="F_BENE_ACR" type="string"/>
<property name="seqNum" column="N_BENE_ACR_SEQ" type="string"/>
<property name="startDt" column="D_BENE_ACR_STRT" type="string"/>
<property name="endDt" column="D_BENE_ACR_END" type="string"/>
<property name="wklyAmt" column="A_BENE_ACR_WKLY" type="float"/>
</composite-element>
</set>
</composite-element>
</set>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
Caused by: org.xml.sax.SAXParseException: The content of element type "composite-element" must match "(meta*,parent?,(property|many-to-one|any|nested-composite-element)*)".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:334)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)

Name and version of the database you are using: DB2 UDB8

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 10:35 am 
Newbie

Joined: Mon Aug 15, 2005 10:04 am
Posts: 6
My mapping file is kinda big so I removed some of the other properties that its not complaining about, I accidently removed the first set tag in what I posted above, it is actually correct. The bolded section is what the validator is complaining about. I tried searching the forums but most posts have Sets in them so it returned more results than I could read through, I apologize if this has already been posted.


Mapping documents:
Quote:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.iso.wc.fst.valueobjects.reports">
<class name="Claim" table="ISO25.WCV00422">
<set name="benefits" table="ISO25.WCV00429">
<composite-id name="claimReportKey" class="ClaimReportKey">
<key-property name="customerId" column="N_CO_GRP" type="string"/>
<key-property name="insdRptNum" column="N_INSRD_RPT" type="string"/>
<key-property name="jurisCd" column="C_JRSD_ST" type="string"/>
<key-property name="clmAdminFein" column="I_CLMADM_FEIN" type="string"/>
<key-property name="rptType" column="C_RPT_TYP" type="string"/>
<key-property name="mtc" column="C_MTC" type="string"/>
<key-property name="mtcDt" column="D_MTC" type="date"/>
<key-property name="rptTimestamp" column="H_RPT_TS" type="timestamp"/>
<key-property name="tempFlag" column="F_TMP" type="string"/>
</composite-id>
<set name="benefits" table="ISO25.WCV00429">
<key>
<column name="N_CO_GRP" sql-type="integer"/>
<column name="N_INSRD_RPT" sql-type="string"/>
<column name="C_JRSD_ST" sql-type="string"/>
<column name="I_CLMADM_FEIN" sql-type="string"/>
<column name="C_RPT_TYP" sql-type="string"/>
<column name="C_MTC" sql-type="string"/>
<column name="D_MTC" sql-type="date"/>
<column name="H_RPT_TS" sql-type="timestamp"/>
<column name="F_TMP" sql-type="string"/>
</key>
<composite-element class="Benefit">
<property name="cd" column="C_BENE_TYP" type="string"/>
<property name="includedInTrnsFlag" column="F_INCL_TRNS" type="string"/>
<property name="tempDeleteFlag" column="F_TMP_DEL" type="string"/>
<property name="benEvalStatus" column="C_BENE_EVAL_STUS" type="string"/>
<property name="benStatus" column="C_BENE_STUS" type="string"/>
<property name="seqNum" column="N_BENE_TYP_SEQ" type="string"/>
<property name="benLvlMTC" column="C_BENE_LVL_MTC" type="string"/>
<property name="grossWklyAmt" column="A_GRS_WKLY" type="string"/>
<property name="grossWklyAmtEffDt" column="D_GRS_WKLY_AMT_EFF" type="string"/>
<property name="netWklyAmt" column="A_NET_WKLY" type="string"/>
<property name="netWklyAmtEffDt" column="D_NET_WKLY_AMT_EFF" type="string"/>
<property name="benPeriodStartDt" column="D_BENE_PER_STRT" type="string"/>
<property name="benPeriodThroughDt" column="D_BENE_PER_THRU" type="string"/>
<property name="ClmWks" column="N_BENE_TYP_CLM_WKS" type="string"/>
<property name="clmDays" column="N_BENE_TYP_CLM_DAY" type="string"/>
<property name="amtPaid" column="A_BENE_TYP_AMT_PD" type="float"/>
<property name="paymentIssueDt" column="D_PMT_ISU" type="string"/>
<property name="partialSuspCd" column="C_PRTL_SUSPN" type="string"/>
<property name="denialTxCount" column="N_DNL_TRNS_CNT" type="integer"/>
<set name="benefitChanges" table="ISO25.WCV00430">
<key>
<column name="N_CO_GRP" sql-type="integer"/>
<column name="N_INSRD_RPT" sql-type="string"/>
<column name="C_JRSD_ST" sql-type="string"/>
<column name="I_CLMADM_FEIN" sql-type="string"/>
<column name="C_RPT_TYP" sql-type="string"/>
<column name="C_MTC" sql-type="string"/>
<column name="D_MTC" sql-type="date"/>
<column name="H_RPT_TS" sql-type="timestamp"/>
<column name="F_TMP" sql-type="string"/>
<column name="C_BENE_TYP" sql-type="string"/>
</key>
<composite-element class="BenefitChange">
<property name="benTypeCd" column="C_BENE_TYP" type="string"/>
<property name="cd" column="C_BENE_ACR" type="string"/>
<property name="includedInTrnsFlag" column="F_INCL_TRNS" type="string"/>
<property name="tempDeleteFlag" column="F_TMP_DEL" type="string"/>
<property name="ind" column="F_BENE_ACR" type="string"/>
<property name="seqNum" column="N_BENE_ACR_SEQ" type="string"/>
<property name="startDt" column="D_BENE_ACR_STRT" type="string"/>
<property name="endDt" column="D_BENE_ACR_END" type="string"/>
<property name="wklyAmt" column="A_BENE_ACR_WKLY" type="float"/>
</composite-element>
</set>
</composite-element>
</set>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 10:52 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Solve this by applying correct object hierarchy. And then map this hierarchy appropriately to Hibernate, not by nesting objects in .hbm.
Have a Claim object that has set of Benefits, and Benefit has a set of BenefitsChanges.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:30 am 
Newbie

Joined: Mon Aug 15, 2005 10:04 am
Posts: 6
I do have that as my object model. Claim has a Set of Benefit objects, Benefit has a Set of BenefitChange objects. My question is how do i map that appropriately.

From my mapping file:

<?xml version="1.0"?>
<hibernate-mapping package="com.iso.wc.fst.valueobjects.reports">
<class name="Claim" table="ISO25.WCV00422">
...
<set name="benefits" table="ISO25.WCV00429">
<key>...</key>
<composite-element class="Benefit">
...
<set name="benefitChanges" table="ISO25.WCV00430">
...
</set>
</composite-element>
</set>
</class>

I'm sorry, i see now that I again pasted the wrong xml file. Here it is again, this time i validated it (now only an error with the Set of BenefitChange objects that goes away if i comment out the second set). That first set in my previous post isn't actually in my real mapping file.

Quote:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.iso.wc.fst.valueobjects.reports">
<class name="Claim" table="ISO25.WCV00422">
<composite-id name="claimReportKey" class="ClaimReportKey">
<key-property name="customerId" column="N_CO_GRP" type="string"/>
<key-property name="insdRptNum" column="N_INSRD_RPT" type="string"/>
<key-property name="jurisCd" column="C_JRSD_ST" type="string"/>
<key-property name="clmAdminFein" column="I_CLMADM_FEIN" type="string"/>
<key-property name="rptType" column="C_RPT_TYP" type="string"/>
<key-property name="mtc" column="C_MTC" type="string"/>
<key-property name="mtcDt" column="D_MTC" type="date"/>
<key-property name="rptTimestamp" column="H_RPT_TS" type="timestamp"/>
<key-property name="tempFlag" column="F_TMP" type="string"/>
</composite-id>
<set name="benefits" table="ISO25.WCV00429">
<key>
<column name="N_CO_GRP" sql-type="integer"/>
<column name="N_INSRD_RPT" sql-type="string"/>
<column name="C_JRSD_ST" sql-type="string"/>
<column name="I_CLMADM_FEIN" sql-type="string"/>
<column name="C_RPT_TYP" sql-type="string"/>
<column name="C_MTC" sql-type="string"/>
<column name="D_MTC" sql-type="date"/>
<column name="H_RPT_TS" sql-type="timestamp"/>
<column name="F_TMP" sql-type="string"/>
</key>
<composite-element class="Benefit">
<property name="cd" column="C_BENE_TYP" type="string"/>
<property name="includedInTrnsFlag" column="F_INCL_TRNS" type="string"/>
<property name="tempDeleteFlag" column="F_TMP_DEL" type="string"/>
<property name="benEvalStatus" column="C_BENE_EVAL_STUS" type="string"/>
<property name="benStatus" column="C_BENE_STUS" type="string"/>
<property name="seqNum" column="N_BENE_TYP_SEQ" type="string"/>
<property name="benLvlMTC" column="C_BENE_LVL_MTC" type="string"/>
<property name="grossWklyAmt" column="A_GRS_WKLY" type="string"/>
<property name="grossWklyAmtEffDt" column="D_GRS_WKLY_AMT_EFF" type="string"/>
<property name="netWklyAmt" column="A_NET_WKLY" type="string"/>
<property name="netWklyAmtEffDt" column="D_NET_WKLY_AMT_EFF" type="string"/>
<property name="benPeriodStartDt" column="D_BENE_PER_STRT" type="string"/>
<property name="benPeriodThroughDt" column="D_BENE_PER_THRU" type="string"/>
<property name="ClmWks" column="N_BENE_TYP_CLM_WKS" type="string"/>
<property name="clmDays" column="N_BENE_TYP_CLM_DAY" type="string"/>
<property name="amtPaid" column="A_BENE_TYP_AMT_PD" type="float"/>
<property name="paymentIssueDt" column="D_PMT_ISU" type="string"/>
<property name="partialSuspCd" column="C_PRTL_SUSPN" type="string"/>
<property name="denialTxCount" column="N_DNL_TRNS_CNT" type="integer"/>
<set name="benefitChanges" table="ISO25.WCV00430">
<key>
<column name="N_CO_GRP" sql-type="integer"/>
<column name="N_INSRD_RPT" sql-type="string"/>
<column name="C_JRSD_ST" sql-type="string"/>
<column name="I_CLMADM_FEIN" sql-type="string"/>
<column name="C_RPT_TYP" sql-type="string"/>
<column name="C_MTC" sql-type="string"/>
<column name="D_MTC" sql-type="date"/>
<column name="H_RPT_TS" sql-type="timestamp"/>
<column name="F_TMP" sql-type="string"/>
<column name="C_BENE_TYP" sql-type="string"/>
</key>
<composite-element class="BenefitChange">
<property name="benTypeCd" column="C_BENE_TYP" type="string"/>
<property name="cd" column="C_BENE_ACR" type="string"/>
<property name="includedInTrnsFlag" column="F_INCL_TRNS" type="string"/>
<property name="tempDeleteFlag" column="F_TMP_DEL" type="string"/>
<property name="ind" column="F_BENE_ACR" type="string"/>
<property name="seqNum" column="N_BENE_ACR_SEQ" type="string"/>
<property name="startDt" column="D_BENE_ACR_STRT" type="string"/>
<property name="endDt" column="D_BENE_ACR_END" type="string"/>
<property name="wklyAmt" column="A_BENE_ACR_WKLY" type="float"/>
</composite-element>
</set>
</composite-element>
</set>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:31 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Use different files. Not pushing everything into one file.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:38 am 
Newbie

Joined: Mon Aug 15, 2005 10:04 am
Posts: 6
To use a different file don't I need to make the Benefit objects and Benefit Change objects entities? I'd rather not do that, Benefits and their changes don't reside outside of the scope of a claim and the claim key is somewhat large (9 fields) which I'd rather not add these two small classes.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:44 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Ok. My mistake. Use just one .hbm.xml file.
But define new classes in it - for Claim, Benefit and BenefitChanges.
And then map them appropriately.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 1:56 pm 
Newbie

Joined: Mon Aug 15, 2005 10:04 am
Posts: 6
I do have three java classes, Claim, Benefit and BenefitChange. What do you mean define new classes in it? In java or in my mapping file. Can you give me a specific example? I believe my problem is how to map such a relationship appropriately.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 2:01 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
In mapping file.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 2:45 pm 
Newbie

Joined: Mon Aug 15, 2005 10:04 am
Posts: 6
Looking through the DTD I think I found my answer and it looks like I'll need to make the Benefit class an entity:

<!-- A composite element allows a collection to hold instances of an arbitrary
class, without the requirement of joining to an entity table. Composite elements
have component semantics - no shared references and ad hoc null value semantics.
Composite elements may not hold nested collections. -->

<!ELEMENT composite-element (
(meta*),
parent?,
(property|many-to-one|any|nested-composite-element)*
)>


This is what a set is allowed to have. I'll need to use a one-to-many entity.

<!ELEMENT set (
meta*,
subselect?,
cache?,
synchronize*,
comment?,
key,
(element|one-to-many|many-to-many|composite-element|many-to-any),
loader?,sql-insert?,sql-update?,sql-delete?,sql-delete-all?,
filter*
)>


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