-->
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.  [ 4 posts ] 
Author Message
 Post subject: mapping of two nested elements with xdoclet
PostPosted: Thu Jan 01, 2004 7:35 pm 
Newbie

Joined: Sun Dec 28, 2003 4:35 pm
Posts: 13
Hello,

I'd like to reproduce the mapping for the Cat example from the doc. I am not able to generate a column element within an id element.

What I would like to generate (id element with nested column element with sql-type attribute):
Code:
...
<id name="id" type="string" unsaved-value="null" >
  <column name="CAT_ID" sql-type="char(32)" not-null="true"/>
  <generator class="uuid.hex"/>
</id>
...



One of my best trials:
in:
* @hibernate.column
* column="CAT_ID"
* sql-type="char(32)"
* not-null="true"
* @hibernate.id
* column="CAT_ID"
* unsaved-value="null"
* generator-class="uuid.hex"
* type="string"

out:
Code:
...       
       <id
            name="id"
            column="CAT_ID"
            type="string"
            unsaved-value="null"
        >
            <generator class="uuid.hex">
            </generator>
        </id>
...


For me it is not a concrete technical problem, but I'd like to know, if one can map anything using xdoclet or if there are some limitations.

Thanks, Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 01, 2004 7:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Currently the @hibernate.column xdoclet tags are only considered for properties, not for ids


Top
 Profile  
 
 Post subject: Re: mapping of two nested elements with xdoclet
PostPosted: Fri Jan 02, 2004 8:00 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
rimmele7 wrote:
For me it is not a concrete technical problem, but I'd like to know, if one can map anything using xdoclet or if there are some limitations.


There are some limitations. Some patch has benn made to correct some. Have a look at JIRA

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2004 10:31 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
There are some parts of a Hibernate hbm.xml file that cannot be
generated from XDoclet hibernatedoclet @tags in your source with XDoclet
1.2.b4. In my case, I needed to include:

Code:
<!-- Included by Hibernate XDoclet task into the hbm.xml -->

   <any name="referredToObject" id-type="long">
       <column name="objectClass" length="128" not-null="true"/>
       <column name="objectId" not-null="true"/>
   </any>



in one of my class mappings. So in my source tree I have:

com/galenworks/hibernate/DocumentCrossReference.java
com/galenworks/hibernate/hibernate-properties-DocumentCrossReference.xml

The hibernate-properties-DocumentCrossReference.xml contains the needed snippet. Pointing to the hibernate-properties-*.xml file in the hibernatedoclet mergedir and then running hibernatedoclet includes the snippet at the end of the class tag, ie.

Code:
<!-- =================================================================== -->
<!-- generates the hibernate HBM.XML files and SAR descriptor             -->
<!-- =================================================================== -->

<target name="generate-Hibernate"
            description="Generates Hibernate class descriptor files."
            depends="compile">

<!-- copy additional resources for the Hibernate XDoclet task to the mergedir    -->

    <copy todir="${build.resources}/sar/hibernate">
        <fileset dir="${src.dir}">
            <include name="**/hibernate/hibernate-properties-*.xml"/>
        </fileset>
    </copy>

    <!-- Execute the hibernatedoclet task -->
    <hibernatedoclet
        destdir="${build.resources}/sar/hibernate"
        force="${xdoclet.force}"
        mergedir="${build.resources}/sar/hibernate"
        verbose="false">
       
        <fileset dir="${src.dir}">
            <include name="**/hibernate/*.java"/>
        </fileset>
       
        <hibernate version="2.0"/>

    </hibernatedoclet>
</target>


Generates:


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

<hibernate-mapping>
    <class
        name="com.galenworks.procedurelink.hibernate.DocumentCrossReference"
        table="DocumentXref"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="documentXrefId"
            column="documentXrefId"
            type="long"
        >
            <generator class="sequence">
                <param name="sequence">documentXrefSeq</param>
            </generator>
        </id>

        <property
            name="documentXPath"
            type="string"
            update="true"
            insert="true"
            column="documentXPath"
            length="255"
            not-null="true"
        />


[snip]


<!-- Included by Hibernate XDoclet task into the hbm.xml -->

   <any name="referredToObject" id-type="long">
       <column name="objectClass" length="128" not-null="true"/>
       <column name="objectId" not-null="true"/>
   </any>

    </class>

</hibernate-mapping>



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