-->
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: Adding a not-null attribut to a key tag
PostPosted: Fri May 27, 2005 10:41 am 
Newbie

Joined: Fri May 27, 2005 8:40 am
Posts: 1
Hello

I'm using hibernate 3.0 and xdoclets and trying to get a XML mapping that looks like:

Code:
<hibernate-mapping  >
        <class name="hibernate.test.Person" table="PERSONS" lazy="false" >
                ....
               
                <bag name="addresses" lazy="false" cascade="all-delete-orphan">
                   <key column="personId" not-null="true" />
                   <one-to-many class="hibernate.test.Address" />
                </bag>             
        </class>

</hibernate-mapping>


My problem is getting the key element right!.

My getAddress() method of my Person class looks like:

...
Code:
   /**
    * @return
    *
    * @hibernate.bag
    *    lazy="false"
    *    cascade="all-delete-orphan"
    *
    * @hibernate.collection-key
    *    column="personId"
    *   not-null="true"
    *
    * @hibernate.collection-key-column
    *    name="personId"
    *    not-null="true"
    *
    * @hibernate.collection-one-to-many
    *   class="hibernate.test.Address"
    */
   public List getAddresses() {
      return addresses;
   }



However when I run generate my XML files I get something like
Code:
        <bag name="addresses" lazy="false" cascade="all-delete-orphan">
            <key>
                <column name="personId" not-null="true" />
            </key>
            <one-to-many class="hibernate.test.Address" />
      </bag>


And my little test program fails to save my data (It works fine if I use the fist mapping. My problem is thus adding a not-null attribute to the key element.

Anybody have an idea how to do that?

I've managed to by-pass the problem by removing all xdoclets tag from the getAddress method and using and extension file but that is tedious and removes all the benefit of using xdoclets (ie having to manage two files for one class).

William


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