-->
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.  [ 11 posts ] 
Author Message
 Post subject: I like xdoclet but ...
PostPosted: Wed Dec 01, 2004 4:09 am 
Regular
Regular

Joined: Wed Sep 03, 2003 8:04 am
Posts: 55
xdoclet still can NOT work well. I used HibernateXdocletTask to produce *.hbm.xml and it indeed do it. However what it produced is not what i want :(
for example,
Code:
  .i have no 'name' property but xdoclet produced a 'name' property
  .my ID is 'native' but xdoclet produced a 'assigned'
  ...


it seems xdoclet doesnot care about my attribute tags in java source file,and do a default operation ?

any suggestion is appreciated !


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 01, 2004 7:07 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I use it, so do many users. I assure you its not (as) broken as you are suggesting. Could be your doing something wrong? Maybe.

Look at some of the examples linked from the wiki as many are based on Xdoclet.


Top
 Profile  
 
 Post subject: more infomation ...
PostPosted: Fri Dec 03, 2004 10:40 am 
Regular
Regular

Joined: Wed Sep 03, 2003 8:04 am
Posts: 55
thanks for your answer firt. here is ant target used to produce hibernate mapping files:

Code:
   <target name="hbm" depends="compile">
      <taskdef name="hibernatedoclet" classname="xdoclet.modules.hibernate.HibernateDocletTask">
         <classpath>
            <fileset dir="${xdoclet.lib.dir}">
               <include name="*.jar"/>
            </fileset>
         </classpath>
      </taskdef>

      <hibernatedoclet destdir="${classes.dir}" excludedtags="@version,@author,@todo"
            force="true" verbose="true" mergedir="${classes.dir}">
         <fileset dir="${src.dir}">
            <include name="**/dos/*.java"/>
         </fileset>
         <hibernate version="2.0"/>
      </hibernatedoclet>
   </target>


. Question.java

Code:
public class Question
{
   private Long _id;
   private String _subject;

   
   public Question() {}

   /**
    *   @hibernate.id   column="id" generator-class="native"
    */
   public Long getId() {
      return _id;
   }
   public void setId(Long id) {
      _id = id;
   }

   /**
    *   @hibernate.property
    *      column="subject" lenght="30" not-null="true"
    */
   public String getSubject() {
      return _subject;
   }
   public void setSubject(String subject) {
      _subject = subject;
   }
......



When using xdoclet-1.2.2. and run "ant hbm", no output generated :(

it seems xdoclet doesnot see Question.java ?!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 03, 2004 12:54 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:57 am
Posts: 33
Location: Alpharetta, Georgia
Code:
/**
* @hibernate.class
*
*/
public class Question
{
   private Long _id;
   private String _subject;

   
   public Question() {}

   /**
    *   @hibernate.id   column="id" generator-class="native"
    */
   public Long getId() {
      return _id;
   }
   public void setId(Long id) {
      _id = id;
   }

   /**
    *   @hibernate.property
    *      column="subject" lenght="30" not-null="true"
    */
   public String getSubject() {
      return _subject;
   }
   public void setSubject(String subject) {
      _subject = subject;
   }
......


You must tell XDoclet that it is a hibernated class, or subclass.
Look at the difference between class-level and method-level tags.[/quote]


Top
 Profile  
 
 Post subject: sorry,but...
PostPosted: Sat Dec 04, 2004 5:17 am 
Regular
Regular

Joined: Wed Sep 03, 2003 8:04 am
Posts: 55
The folllowing is relativly complete code:
Code:
package com.zsoft.dos;

/**
*   @hibernate.class table="question"
*/
public class Question
{
   private Long _id;
   private String _subject;
   
   public Question() {}

   /**
    *   @hibernate.id   generator-class="sequence" column="id"
    *   @generator-parameter-name="sequence" generator-parameter-value="GEN_POST"
    *      
    */
   public Long getId() {
      return _id;
   }
   public void setId(Long id) {
      _id = id;
   }

   /**
    *   @hibernate.property
    *      column="subject" lenght="30" not-null="true"
    */
   public String getSubject() {
      return _subject;
   }
   public void setSubject(String subject) {
      _subject = subject;
   }

}


d:\ant hbm
Code:
Buildfile: build.xml

init:

compile:
    [javac] Compiling 9 source files to F:\z\usr\src\qa-china\build\WEB-INF\clas
ses

hbm:
[hibernatedoclet] (XDocletMain.start                   47  ) Running <hibernate/
>

BUILD SUCCESSFUL
Total time: 1 minute 15 seconds



but no Question.hbm.xml generated !!!
[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 04, 2004 7:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Two things:

1) You have not configured XDoclet correctly. It is missing the location to use for the output.
For example:
Code:
   <target name="hibernate.xdoclet"
        description="Generates Hibernate mapping files with XDoclet.">

        <hibernatedoclet
            destdir="${src.dir}"
            excludedtags="@version,@author,@todo"
            force="true"
            mergedir="${build.dir}"
            verbose="false">

            <fileset dir="${src.dir}">
                <include name="**/*.java"/>
            </fileset>

            <hibernate version="2.0"/>

        </hibernatedoclet>

    </target>

See destdir attribute.

2) Less importantly, your markup has spelling errors.
Quote:
/**
* @hibernate.property
* column="subject" lenght="30" not-null="true"
*/

The length attribute is not correct. I have not looked that closely, it just jumped out at me.


Top
 Profile  
 
 Post subject: thanks but...
PostPosted: Sun Dec 05, 2004 9:02 am 
Regular
Regular

Joined: Wed Sep 03, 2003 8:04 am
Posts: 55
Code:
<hibernatedoclet
[b]destdir="${classes.dir}" [/b]
excludedtags="@version,@author,@todo"
            force="true" verbose="true" mergedir="${classes.dir}">
         <fileset dir="${src.dir}">
            <include name="**/dos/*.java"/>
         </fileset>
         <hibernate version="2.0"/>
/hibernatedoclet>


i indeed include destdir attribute ?!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 05, 2004 10:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
OK so you did. I missed it due to the formating.
Why is the destination directory in the class.dir (build location) rather than the source directory?
Is a build operation deleting this directory or the contents of it?

Anyway, I suggest you download the tools example package and try it out. It does cover XDoclet and it should provide a working example from which you can explorer and compare with your own installation.


Top
 Profile  
 
 Post subject: got it ...
PostPosted: Tue Dec 07, 2004 3:59 am 
Regular
Regular

Joined: Wed Sep 03, 2003 8:04 am
Posts: 55
sorry to disturb you ! it is a foolish question :(

The *.hbm.xml has been generated successfully but i cannot find it before.
because hbm.xml is put into ${dest-dir}/com/zsoft/dos/ not ${dest-dir}


clever xdoclet ,right ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 6:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Yes the dist directory is the base directory as XDoclet does a recursive search for all *.java files from the fileset.


Top
 Profile  
 
 Post subject: Re: got it ...
PostPosted: Wed Dec 08, 2004 9:34 am 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
midas wrote:
sorry to disturb you ! it is a foolish question :(

The *.hbm.xml has been generated successfully but i cannot find it before.
because hbm.xml is put into ${dest-dir}/com/zsoft/dos/ not ${dest-dir}


clever xdoclet ,right ?


Yep. pretty clever :) It respects your package structure and places generated mapping alongside with class file ( where hibernate will look for it, if you register classes in confuguration )

If you are plagued by typos in xdoclet tags, go for xdoclet-2. It validates them...

_________________
Got new hibernate xdoclet plugin? http://www.sourceforge.net/projects/xdoclet-plugins/
... Momentan auf der Suche nach neuen Projekt ode Festanstellung....


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