-->
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.  [ 7 posts ] 
Author Message
 Post subject: XDoclet2 problem with derived persistent classes
PostPosted: Tue May 17, 2005 3:29 pm 
Beginner
Beginner

Joined: Thu Dec 25, 2003 8:08 am
Posts: 26
I'm using XDoclet to generate my mapping files. I have sereval persistent classes which inherit persistent properties from a base class.
XDoclet 1 was detecting the whole set of properties from the derived and base classes whereas XDoclet2 ignores the inherited properties.

Am I missing someting?
Any help would be appriciated.

My Ant task looks like this:
Code:
<project name="xdoclet-sample" default="xdoclet">
   <property name="devlib.home" value="../lib"/>
   <property name="lib.home" value="../../../image/bin/lib"/>
   <property name="generate.force" value="false"/>
   <property name="src1.home" value="../../mod_datastore/src"/>
   <property name="dst.home" value="../../../image/data/management/hibernate"/>
   <property name="generated.package" value="**com/eyeclick/"/>
   <target name="xdoclet">
      <taskdef name="xdoclet" classname="org.xdoclet.ant.XDocletTask">
         <classpath>
               <pathelement location="${devlib.home}/xdoclet2"/>
            <fileset dir="${devlib.home}">
               <include name="ant*.jar"/>
            </fileset>
            <fileset dir="${devlib.home}/xdoclet2">
               <include name="*.jar"/>
            </fileset>
            <fileset dir="${lib.home}">
               <include name="*.jar"/>
            </fileset>
         </classpath>
      </taskdef>
      <xdoclet>
         <!-- defines the file handled by xdoclet2 -->
         <fileset dir="${src1.home}">
            <include name="${generated.package}**/*BO.java"/>
            <exclude name="${generated.package}**/test/*"/>
         </fileset>
         <!-- defines the processing of a plugin -->
         <component classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin" destdir="${dst.home}" version="3.0"/>
      </xdoclet>
   </target>
</project>


Hibernate version:
3.0


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 2:45 am 
Beginner
Beginner

Joined: Fri Mar 12, 2004 1:12 pm
Posts: 25
Location: Minsk, Belarus
XDoclet2 Hibernate plugin definitely collects all properties from all base classes and interfaces. I am using it in my project so I am sure about it.

Could you provide more info (probably code of some of your classes) then I'll answer to you more accurately.

It will be better to continue our discussion in project maillist http://sourceforge.net/mail/?group_id=88133 . All your questions will be answered much faster there.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 3:02 am 
Beginner
Beginner

Joined: Thu Dec 25, 2003 8:08 am
Posts: 26
Here is my code sample:

Base class:
Code:
package com.test;

/**
* <p>Title: BusinessObject</p>
*/
public abstract class BusinessObject {
    // the object unique identifier
    private ID m_id;

    // the object persistent version
    private int m_version;

    /**
     *
     * @return m_id
     * @hibernate.id
     *  generator-class="com.test.IdGenerator"
     *  column="Id"
     *  unsaved-value="0"
     */
    protected long getInternalId() {
        if (m_id == null) {
            return 0;
        }
        return m_id.getInternalID();
    }

    /**
     * @param id  unique identifier
     */
    protected void setInternalId(long id) {
        if (id != 0) {
            m_id = new PersistentID(id);
        }
    }

    /**
     * @return m_version
     * @hibernate.version
     */
    public int getVersion() {
        return m_version;
    }

    /**
     * @param version  persistent version
     */
    public void setVersion(int version) {
        m_version = version;
    }
}


Derived class:
Code:
package com.test;

import com.test.BusinessObject;

/**
*
* @hibernate.class table="Event"
*/
public class EventBO extends BusinessObject {
    // data members
    private String m_message = null;
    private long m_timestamp = 0;

    /**
     * Ctor
     */
    public EventBO() {
    }

    /**
     * @return
     * @hibernate.property
     */
    public String getMessage() {
        return m_message;
    }

    /**
     * @param message
     */
    public void setMessage(String message) {
        m_message = message;
    }

    /**
     * @return
     * @hibernate.property
     */
    public long getTimestamp() {
        return m_timestamp;
    }

    /**
     * @param timestamp
     */
    public void setTimestamp(long timestamp) {
        m_timestamp = timestamp;
    }

}


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 3:18 am 
Beginner
Beginner

Joined: Fri Mar 12, 2004 1:12 pm
Posts: 25
Location: Minsk, Belarus
You should include BusinessObject to set of processed sources.
XDoclet reads metadata only from included files.

<xdoclet>
<!-- defines the file handled by xdoclet2 -->
<fileset dir="${src1.home}">
<include name="${generated.package}/<path>/BusinessObject.java"/>
<include name="${generated.package}**/*BO.java"/>
<exclude name="${generated.package}**/test/*"/>
</fileset>
<!-- defines the processing of a plugin -->
<component classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin" destdir="${dst.home}" version="3.0"/>
</xdoclet>


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 3:25 am 
Beginner
Beginner

Joined: Thu Dec 25, 2003 8:08 am
Posts: 26
Great, thanks.
Two comments:
1. I think it would be better if the XDoclet would warn me if it can't find the base classes of persistent classes.
2. It was working with XDoclet 1

BTW. how do I tell XDoclet to create all files in a flat structrue (single folder) rather than in packages structrue?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 3:37 am 
Beginner
Beginner

Joined: Fri Mar 12, 2004 1:12 pm
Posts: 25
Location: Minsk, Belarus
Quote:
1. I think it would be better if the XDoclet would warn me if it can't find the base classes of persistent classes.
2. It was working with XDoclet 1

Please post it to xdoclet-plugins JIRA tracker. jira.codehaus.org/browse/XDP

Quote:
BTW. how do I tell XDoclet to create all files in a flat structrue (single folder) rather than in packages structrue?

You can't. Why do you need it??

If you want to simplify your hibernate.cfg.xml then you can use
Code:
org.xdoclet.plugin.hibernate.HibernateConfigPlugin
plugin which helps you generate config file.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 3:49 am 
Beginner
Beginner

Joined: Thu Dec 25, 2003 8:08 am
Posts: 26
Currently, my code is configuring Hibernate programatically so I'm not using an external configuration file. It's a lot simpler if all files exist in the same folder.


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