-->
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.  [ 15 posts ] 
Author Message
 Post subject: @hibernate.id
PostPosted: Sun Feb 29, 2004 3:38 pm 
Regular
Regular

Joined: Fri Jan 16, 2004 4:48 am
Posts: 56
It seems that Hibernate.id tag does not support the nested column tag. Is there away to get around this. I did see that there this issue raised in the JIRA, but haven't come across any solution. Any tips, hints??

Thanks
Shishir


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 29, 2004 8:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
No. Embeded composite keys are not implemented in Xdoclet (as yet). You can have external composite key classes (which is the recommended approach). The Key properites are Xdoclet hibernate properties on the methods of the class that represents the composite key.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 29, 2004 10:04 pm 
Regular
Regular

Joined: Fri Jan 16, 2004 4:48 am
Posts: 56
Aagh...I meant using the column tag to define the sql type within the id tag. Eg. For Long, the default is NUMBER(19,0) that gets created by the xdoclet. I would like to change this to NUMBER(15,0). The only way to do this is to use the column tag withing the id.

Thanks
Shishir


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 29, 2004 11:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
OK now I understand.
XDoclet markup mirrors the mapping XML DTD in that there is no attribute for sql-type for the id property. In this case you do need to use the nested column tag to set this option. So no workaround since Xdoclet is following hibernate's features.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 29, 2004 11:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I have been assuming that you have used both the @hibernate.id and the @hibernate.column (for nested tag generation) for your id Xdoclet markup. You just did not like the solution. This does work and addresses your issue (unless you did not want two @hibernate markup lines for the id property).


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 29, 2004 11:58 pm 
Regular
Regular

Joined: Fri Jan 16, 2004 4:48 am
Posts: 56
I did try

@hibernate.id
------
@hibernate.column
-----

assuming that it would generate something like this (as it does for the other properties in conjunction with @hibernate.property)

<id name = "aaa" ...... >
<column ....../>
</id>

But does not work that way. However, i can hand edit the mapping file and create the proper schema.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 12:21 am 
Regular
Regular

Joined: Fri Jan 16, 2004 4:48 am
Posts: 56
The JIRA issue that I am talking about is:


http://opensource.atlassian.com/projects/xdoclet/secure/ViewIssue.jspa?key=XDT-737


I am trying

/**
* @hibernate.id
* name="id"
* unsaved-value="null"
* type="long"
* generator-class="native"
* @hibernate.column
* name="ID"
* sql-type="NUMBER(15,0)"
*
*/


But this is not working. It still creates as (for oracle)

<id name="id" column="id" type="long" unsaved-value="null">
<generator class="native" />
</id>

This results in a schema being created with id as NUMBER(19,0).

Where as what I want is this :


<id name="id" column="id" type="long" unsaved-value="null">
<generator class="native" />
<column name="id" sql-type="NUMBER(15,0) />
</id>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 3:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I checked the Xdoclet source and I was mistaken. I really thought this was taken care of - sorry :-).

It should not be hard to fix - edit the hibernate.xdt file. You will find about 1/3 the way down the entry for the id tag. You need to add the inclusion of the hibernate-property/xdt file. For example the lines to add will look something like:

Code:
          <XDtHibernate:setCurrentTag name="hibernate.id" mappingElement="id">
              <XDtMerge:merge file="xdoclet/modules/hibernate/resources/hibernate-column.xdt">
              </XDtMerge:merge>
          </XDtHibernate:setCurrentTag>


This will go into the following hibernate.xdt section like this (changes are towards the end):
Code:
    <XDtHibernate:ifHasPrimitiveId>
        <id
            name="<XDtMethod:propertyName/>"
            column="<XDtMethod:methodTagValue tagName="hibernate.id" paramName="column" default="<XDtMethod:propertyName/>" />"
            type="<XDtMethod:methodTagValue tagName="hibernate.id" paramName="type" default="<XDtMethod:methodType/>" />"
          <XDtMethod:ifHasMethodTag tagName="hibernate.id" paramName="length">
            length="<XDtMethod:methodTagValue tagName="hibernate.id" paramName="length" />"
          </XDtMethod:ifHasMethodTag>
          <XDtMethod:ifHasMethodTag tagName="hibernate.id" paramName="unsaved-value">
            unsaved-value="<XDtMethod:methodTagValue tagName="hibernate.id" paramName="unsaved-value" />"
          </XDtMethod:ifHasMethodTag>
        >
            <generator class="<XDtMethod:methodTagValue tagName="hibernate.id" paramName="generator-class" />">
              <XDtMethod:forAllMethodTags tagName="hibernate.generator-param" >
                <param<XDtConfig:ifConfigParamEquals paramName="version" value="2.0"> name="<XDtMethod:methodTagValue tagName="hibernate.generator-param" paramName="name" />"</XDtConfig:ifConfigParamEquals>><XDtMethod:methodTagValue tagName="hibernate.generator-param" paramName="value" /></param>
              </XDtMethod:forAllMethodTags>
              <XDtMethod:ifHasMethodTag tagName="hibernate.id" paramName="generator-parameter-1">
                <param><XDtMethod:methodTagValue tagName="hibernate.id" paramName="generator-parameter-1" /></param>
              </XDtMethod:ifHasMethodTag>
              <XDtMethod:ifHasMethodTag tagName="hibernate.id" paramName="generator-parameter-2">
                <param><XDtMethod:methodTagValue tagName="hibernate.id" paramName="generator-parameter-2" /></param>
              </XDtMethod:ifHasMethodTag>
              <XDtMethod:ifHasMethodTag tagName="hibernate.id" paramName="generator-parameter-3">
                <param><XDtMethod:methodTagValue tagName="hibernate.id" paramName="generator-parameter-3" /></param>
              </XDtMethod:ifHasMethodTag>
            </generator>
          <XDtHibernate:setCurrentTag name="hibernate.id" mappingElement="id">
              <XDtMerge:merge file="xdoclet/modules/hibernate/resources/hibernate-column.xdt">
              </XDtMerge:merge>
          </XDtHibernate:setCurrentTag>
        </id>
    </XDtHibernate:ifHasPrimitiveId>


I have not tried it. If you don't go ahead and try it out please tell me as I will follow this up and make sure that this works (or make it work) and submit to JIRA for someone to commit (I don't have commit rights for Xdoclet).

Hope this helps.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 11:24 am 
Regular
Regular

Joined: Fri Jan 16, 2004 4:48 am
Posts: 56
Thanks David. I will try it out. If it works, well and fine, although I would like this to incorporated in the xdoclet so that I don't have to worry about my code getting broken when the next release comes in :).

Shishir


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 11:30 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
If it proves to work (or you get it to work) then post the patch (attach it) to the JIRA entry. I am sure someone will commit it to XDoclet source tree.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 02, 2004 4:53 am 
Regular
Regular

Joined: Fri Jan 16, 2004 4:48 am
Posts: 56
Sorry David...no luck :(. I tried the patch that is attached to the JIRA (pls see the link in the previous note)..but that also seems buggy., although it comes pretty much near to what is required. Just does not takes care of the other tags like many-to-one..etc. I am givin g it up for the timebeing. Will just have to hand edit the file. Will look into it when I get some free time.

Would appreciate it if you could take it up with the proper person.

Thanks
Shishir


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 02, 2004 6:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Cool - thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 02, 2004 8:10 pm 
Regular
Regular

Joined: Fri Jan 16, 2004 4:48 am
Posts: 56
All right ....I have changed and uploaded the adffected files vide xdoclet JIRA

http://opensource.atlassian.com/projects/xdoclet/secure/ViewIssue.jspa?key=XDT-827

Hope haven't broken anything in the process :).

Shishir


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 21, 2004 5:02 pm 
Newbie

Joined: Wed Apr 21, 2004 1:13 pm
Posts: 1
I am exactly with this problem here.
In what xdoclet version I must apply this patch ? Any 1.2.x will work ?
In the JIRA there are 2 versions of the hibernate-column.xdt and hibernate.xdt files. What is correct ? There are a comment about the 3/march version be correct but where is it ?
How I will look my tags on .java ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 06, 2004 12:12 pm 
Regular
Regular

Joined: Fri Jan 16, 2004 4:48 am
Posts: 56
The latest 1.2x xdoclet version has this fix.


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