-->
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: Use xdoclet to generate Hibernate files
PostPosted: Sun Oct 26, 2003 2:56 am 
Newbie

Joined: Tue Oct 21, 2003 11:41 am
Posts: 11
Hi,

I have 2 questions about using xdoclet with hibernate.
1. how can I use hibernate to generate the hibernate.cfg.xml file?

2. how to generate the column mapping for id in my <class>.cfg.xml file:
<id name="id" type="string" unsaved-value="null" >
<column name="CAT_ID" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>

I try this, but what I put in the xdoclet, but the column mapping does not generate

/* @hibernate.id generator-class="uuid.hex" column="CAT_ID" unsaved-value="null"
* @hibernate.column name="CAT_ID" sql-type="char(32)" not-null="true"
*/

this is what I get in the generated <class>.cfg.xml file (there is no 'column' children under 'id'):
<id
name="id"
column="CAT_ID"
type="java.lang.String"
unsaved-value="null"
>
<generator class="uuid.hex">
</generator>
</id>

I read the hibernate workshop presentation, but that does seems to answer my question. So I appreciate someone can help me.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 7:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I'm not an expert on Xdoclet:
1) Not that I can see. Can generate the JBoss service file.
2) It appears to be the external column atttribute cannot be applied to the id in Xdoclet markup. To confirm for yourself, you can view the Xdoclet markup in the xdoclect-hibernate jar file (I was looking at the (almost latest) CVS version).


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 2:09 pm 
Newbie

Joined: Tue Oct 21, 2003 11:41 am
Posts: 11
Thanks.

For question #2, it is actaully from the Cat example. In the Cat.hbm.xml file,

It has this:
<id name="id" type="string" unsaved-value="null" >
<column name="CAT_ID" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>

My question is why this line is necessary? '<column name="CAT_ID" sql-type="char(32)" not-null="true"/>'? I guess this is useful only for database creation, and Cat.hbm.xml is NOT for database creation, so why we need to put that in our Cat.hbm.xml file?

Can't I just do this instead:
<id name="id" type="string" unsaved-value="null" column="CAT_ID">
<generator class="uuid.hex"/>
</id>

Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 26, 2003 6:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Oh OK. The separate column tag is required for the sql-type attribute. This is used if you want the schema generator tool to use the defined type rather than the default from the dialect. Otherwise there is not advantage. Most use the shortened version.


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.