-->
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: Need help mapping 3 compound keys for 1 audit table
PostPosted: Thu Jan 18, 2007 8:41 pm 
Newbie

Joined: Mon Jun 20, 2005 12:40 pm
Posts: 5
I have the following:

PRoviderHistory
--------------------
ProviderIdentifier (not unique (pk))
HistoryCreateUser (pk)
HistoryCreateDateTIme (pk)

I need this mapped and composite-id is giving me errors.




Hibernate version: 3.2.0.g

Mapping documents:

Code:
<?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">

<hibernate-mapping
>
    <class
        name="org.delta.provider.npi.data.ProviderHistory"
        table="PROVIDERHISTORY"
        polymorphism="explicit"
    >
        <cache usage="read-write" />

        <id
            name="providerIdentifier"
            column="PROVIDERIDENTIFIER"
            type="long"
        >
            <generator class="provided">
            </generator>
        </id>



        <composite-id>
            <key-property
                    name="providerIdentifier"
                    type="long"
                    column="PROVIDERIDENTIFIER"/>
            <key-property
                    name="historyCreateUser"
                    type="java.lang.String"
                    column="HISTORYCREATEUSER"/>
            <key-property
                    name="historyCreateDateTime"
                    type="java.util.Date"
                    column="HISTORYCREATEDATETIME"/>
        </composite-id>


        <property
            name="providerIdentifier"
            type="long"
            update="false"
            insert="false"
            column="PROVIDERIDENTIFIER"
            unique="false"
        />

        <property
            name="firstName"
            type="java.lang.String"
            update="true"
            insert="true"
            column="PROVIDERFIRSTNAME"
        />

        <property
            name="lastName"
            type="java.lang.String"
            update="true"
            insert="true"
            column="PROVIDERLASTNAME"
        />

        <property
            name="middleName"
            type="java.lang.String"
            update="true"
            insert="true"
            column="PROVIDERMIDDLENAME"
        />

        <property
            name="facilityName"
            type="java.lang.String"
            update="true"
            insert="true"
            column="FACILITYNAME"
        />

        <property
            name="facilityNumber"
            type="java.lang.String"
            update="true"
            insert="true"
            column="FACILITYNUMBER"
        />

        <property
            name="addressLine1"
            type="java.lang.String"
            update="true"
            insert="true"
            column="ADDRESSLINE1"
        />

        <property
            name="addressLine2"
            type="java.lang.String"
            update="true"
            insert="true"
            column="ADDRESSLINE2"
        />

        <property
            name="city"
            type="java.lang.String"
            update="true"
            insert="true"
            column="CITY"
        />

        <property
            name="stateCode"
            type="java.lang.String"
            update="true"
            insert="true"
            column="STATECODE"
        />

        <property
            name="zipCode"
            type="java.lang.String"
            update="true"
            insert="true"
            column="ZIPCODE"
        />

        <property
            name="planCode"
            type="java.lang.String"
            update="true"
            insert="true"
            column="PLANCODE"
        />

        <property
            name="systemIdentifier"
            type="java.lang.String"
            update="true"
            insert="true"
            column="SYSTEMIDENTIFIER"
        />

        <property
            name="taxIdentifier"
            type="java.lang.String"
            update="true"
            insert="true"
            column="TAXIDENTIFIER"
        />

        <property
            name="individualIdentifier"
            type="java.lang.String"
            update="true"
            insert="true"
            column="INDIVIDUALPROVIDERIDENTIFIER"
        />

        <property
            name="officeIdentifier"
            type="java.lang.String"
            update="true"
            insert="true"
            column="OFFICEPROVIDERIDENTIFIER"
        />

        <property
            name="businessIdentifier"
            type="java.lang.String"
            update="true"
            insert="true"
            column="BUSINESSPROVIDERIDENTIFIER"
        />

        <property
            name="baseLicenseNumber"
            type="java.lang.String"
            update="true"
            insert="true"
            column="BASELICENSENUMBER"
        />

        <property
            name="baseLicenseStateCode"
            type="java.lang.String"
            update="true"
            insert="true"
            column="BASELICENSESTATECODE"
        />

        <property
            name="clientCode"
            type="java.lang.String"
            update="true"
            insert="true"
            column="CLIENTCODE"
        />

        <property
            name="specialtyCode"
            type="java.lang.String"
            update="true"
            insert="true"
            column="SPECIALTYCODE"
        />

        <property
            name="specialtyType"
            type="java.lang.String"
            update="true"
            insert="true"
            column="SPECIALTYTYPE"
        />

        <property
            name="logicalDeleteFlag"
            type="int"
            update="true"
            insert="true"
            column="LOGICALDELETEFLAG"
        />

        <property
            name="updateUser"
            type="java.lang.String"
            update="true"
            insert="true"
            column="UPDATEUSER"
        />

        <property
            name="updateDateTime"
            type="java.util.Date"
            update="true"
            insert="true"
            column="UPDATEDATETIME"
        />

        <property
            name="historyCreateUser"
            type="java.lang.String"
            update="true"
            insert="true"
            column="HISTORYCREATEUSER"
        />

        <property
            name="historyCreateDateTime"
            type="java.util.Date"
            update="true"
            insert="true"
            column="HISTORYCREATEDATETIME"
        />


    </class>

</hibernate-mapping>




Full stack trace of any exception that occurs:
Code:
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|comp
osite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idba
g|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-qu
ery)*)".
        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.XMLDocumentFragmentScannerImpl.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.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
        at org.dom4j.io.SAXReader.read(SAXReader.java:339)
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:460)
        ... 169 more



Name and version of the database you are using: Oracle 10g


[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 12:26 am 
Newbie

Joined: Thu Jan 18, 2007 12:55 am
Posts: 10
You have a primary key called PROVIDERIDENTIFIER. when having a primary key mapping file shouldn't have a composite-id mapping. composite key are combination of keys that is the primary key, so having <id> attribute
you shouldn't have composite key

<composite-id>
<key-property
name="providerIdentifier"
type="long"
column="PROVIDERIDENTIFIER"/>
<key-property
name="historyCreateUser"
type="java.lang.String"
column="HISTORYCREATEUSER"/>
<key-property
name="historyCreateDateTime"
type="java.util.Date"
column="HISTORYCREATEDATETIME"/>
</composite-id>

instead of have these key as composite keys create a many-to-one relationship
for each key with the corresponding table,
try that it should fix the problem,
the error below , is saying that mapping xml document doesn't confirm to this dtd that is mentioned below

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 19, 2007 1:10 pm 
Newbie

Joined: Mon Jun 20, 2005 12:40 pm
Posts: 5
That was the trick...
Thanks!


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.