-->
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: XDoclet2 and "any" mapping
PostPosted: Tue Jun 12, 2007 11:04 pm 
Newbie

Joined: Tue Jun 12, 2007 10:53 pm
Posts: 2
Hello,

I have some problems getting the "any" mapping to be generated correctly with XDoclet2.

Here's what I am doing:

Code:
public class AnimalContainer {
...
    /**
     * @hibernate.any id-type="long" meta-type="string"
     * @hibernate.meta-value class="my.package.Dog" value="DOG"
     * @hibernate.meta-value class="my.package.Cat" value="CAT"
     * @hibernate.column name="animal_type"
     * @hibernate.column name="animal_id"
     */
    public Animal getAnimal ()
    {
        return animal;
    }
...
}


Here, Animal is an interface and Dog and Cat do not inherit from a base class (for some specific reasons...) but implement the Animal interface.

When generating the hbm, XDoclet2 chokes and throws:

Code:
[xdoclet2] Running org.xdoclet.plugin.hibernate.HibernateMappingPlugin
[xdoclet2]   * Generate mapping for 'AnimalContainer' entity
[xdoclet2] File /.../AnimalContainer.hbm.xml did not pass validation:
[xdoclet2]    Line: 18 Column: 11
[xdoclet2]    Message: The content of element type "any" is incomplete, it must match "(meta*,meta-value*,column,column+)".



The content of the hbm.xml file contains:
Code:
    <any name="source" id-type="long" meta-type="string">
      <meta-value class="my.package.Dog" value="DOG"/>
      <meta-value class="my.package.Cat" value="CAT"/>
    </any>

which is mising half of what I put in the JavaDoc...

Any clue what's wrong with my mapping?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 11:56 pm 
Newbie

Joined: Tue Jun 12, 2007 10:53 pm
Posts: 2
Argh!

The correct mapping was:

Code:
    /**
     * @hibernate.any id-type="long" meta-type="string"
     * @hibernate.any-column name="animal_type"
     * @hibernate.any-column name="animal_id"
     * @hibernate.meta-value class="my.package.Dog" value="DOG"
     * @hibernate.meta-value class="my.package.Cat" value="CAT"
     */


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 14, 2007 12:09 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Glad you found the answer. Thanks for providing it in the forum for others to be able to read.


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.