-->
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.  [ 1 post ] 
Author Message
 Post subject: Duplicate unique="true" causing exception
PostPosted: Fri Jun 01, 2007 5:22 am 
Newbie

Joined: Wed May 30, 2007 4:45 am
Posts: 8
Location: Cape Town , South Africa
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:2.0

Mapping documents:<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
<class
name="za.co.introspect.portal.Person"
lazy="true"
>

<id
name="id"
column="person_id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Person.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

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

<property
name="termsAndConditions"
type="java.lang.String"
update="true"
insert="true"
column="terms_and_conditions"
length="10"
/>

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

<many-to-one
name="demographics"
class="za.co.introspect.portal.Demographics"
cascade="all"
outer-join="auto"
update="true"
insert="true"
column="Demographics_id"
/>

<property
name="activationKey"
type="java.lang.String"
update="true"
insert="true"
column="activationKey"
length="50"
/>

<property
name="associationFailures"
type="java.lang.Long"
update="true"
insert="true"
column="associationFailures"
/>

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

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

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

<property
name="loginFailues"
type="java.lang.Long"
update="true"
insert="true"
column="loginFailues"
/>

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

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

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

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

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

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

<property
name="active"
type="boolean"
update="true"
insert="true"
column="isactive"
/>

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

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

<many-to-one
name="contactDetails"
class="za.co.introspect.portal.ContactDetails"
cascade="save-update"
outer-join="auto"
update="true"
insert="true"
unique="true"
column="contactdetails_id"
not-null="false"
unique="true"
/>

<property
name="idType"
type="java.lang.String"
update="true"
insert="true"
column="idType"
length="40"
/>

<property
name="clarifyContactKeyAudit"
type="java.lang.String"
update="true"
insert="true"
column="clarifyContactKeyAudit"
length="40"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Person.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>



The mapping file above(called Person.hbm.xml) is being generated by xdoclet.When I deploy my application I get a MappingException saying :

Quote:
nested exception is net.sf.hibernate.MappingException:
org.dom4j.DocumentException: Error on line 198 of document : <Line 198, Column 11>: XML-20124: (Fatal Error) An attribute cannot appear
more than once in the same start tag. Nested exception: <Line 198, Column 11>: XML-20124: (Fatal Error) An attribute cannot appear more
than once in the same start tag.
net.sf.hibernate.MappingException: org.dom4j.DocumentException: Error on line 198 of document : <Line 198, Column 11>: XML-20124: (Fatal



Validating the Person.hbm.xml file using XML Spy also gave me an error along the same lines , saying :

Quote:
The element already has an attribute named 'unique'.
Error location: hibernate-mapping / class / many-to-one / @unique
Details :WFC: Unique Att Spec: The element already has an attribute named 'unique'.


The offending section being :
Code:
<many-to-one
            name="contactDetails"
            class="za.co.introspect.portal.ContactDetails"
            cascade="save-update"
            outer-join="auto"
            update="true"
            insert="true"
            [b]unique="true"[/b]
            column="contactdetails_id"
            not-null="false"
           [b] unique="true"[/b]
        />



The mapping is declared in the code as :
Code:
/**
     * @return the contact details linked to the person
     * @hibernate.many-to-one class="za.co.introspect.portal.ContactDetails"
     * cascade="save-update"
     * column="contactdetails_id" not-null="false" unique="true"
     */   
   public ContactDetails getContactDetails() {
      return contactDetails;
   }

   public void setContactDetails(ContactDetails contactDetails) {
      this.contactDetails = contactDetails;
   }



Why am I getting duplicate unique="true" in the generated Person.hbm.xml? Is this an xdoclet issue?


Jeff Mutonho



[/code]


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.