Craig,

I'm doing the exact thing you are talking about. First, I'm using Hibernate
2.0 (basically beta 3/4 - but I built from CVS over the weekend); also a
build of Xdoclet 1.2 beta - again built from CVS over the weekend. About a
week ago, the hibernate xdoclet support was upgraded to work with 2.0 and to
support a lot more of the features of Hibernate in general.

Anyway, I have a BaseObject that contains id, audit fields, version, etc.
There is not @hiberate class or subclass tag, but each of the property
getters are market up with the appropriate @hibernate tags.

Then each persistent class extends BaseObject, supplies its own class or
subclass @hibernate tag and the @hibernate tags for its unique properties.

It works like a champ. Hope this helps.

Richard Mixon

>From LtoJ Software, L.L.C.
Managing Partner
Education Software for Continuous Improvement
mobile: (480) 577-6834 office: (480) 614-3442
email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Craig
Shearer
Sent: Wednesday, March 19, 2003 6:58 PM
To: [EMAIL PROTECTED]
Subject: [Xdoclet-user] Inheritance with hibernate and xdoclet


Hello all

Is there a hibernate expert out there who knows how to do inheritance with
hibernatedoclet?
I have this problem - I'm wanting to persist a class that inherits its ID
from a base class, but hibernatedoclet seems unable to do this. For example:

public class Base
{
        private int id;
        /**
         * @hibernate.id generator-class="assigned"
         */
        private int getId()
        {
                return id;
        }
        private void setId(int id)
        {
                this.id = id;
        }
}

/**
 * @hibernate.class table="Sub"
 */
public class Sub extends Base
{
        private String name;

        /**
         * @hibernate.property
         */
        private String getName()
        {
                return name;
        }
        private void setName(String name)
        {
                this.name = name;
        }
}



So, I'm wanting the Sub class to pick up the id property from Base, and thus
have hibernatedoclet generate the mapping file with id as it's ID field.
However, xdoclet doesn't seem to have any concept of this. The only way I
can see of doing this would be:

/**
 * @hibernate.class table="Sub"
 */
public class Sub extends Base
{
        private String name;
        /**
         * @hibernate.property
         */
        private String getName()
        {
                return name;
        }
        private void setName(String name)
        {
                this.name = name;
        }
        /**
         * @hibernate.id generator-class="assigned"
         */
        private int getId()
        {
                return super.getId();
        }
        private void setId(int id)
        {
                super.setId(id);
        }
}


which seems rather a lot of work to implement my inheritance hierarchy! In
every class, I'd need to include the get/set methods for my ID attribute!

Anybody got any ideas on this? Right now, I don't see how I can use
hibernatedoclet in anything but the simplest of cases (that is, where
there's no inheritance of attributes), and I'm going to have to use
Hibernate's MapGenerator tool to generate skeleton mapping files, and then
complete them by hand.

I did think that maybe merge points were the answer, but these seem to do
their work *after* xdoclet rather than before - I'd like to be able to
insert the superclass method declarations and xdoclet tags before
hibernatedoclet did its thing.

Any help much appreciated...

Craig

Chief Architect
Dyosoft Systems Limited




-------------------------------------------------------
This SF.net email is sponsored by: Does your code think in ink?
You could win a Tablet PC. Get a free Tablet PC hat just for playing.
What are you waiting for?
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user



-------------------------------------------------------
This SF.net email is sponsored by: Does your code think in ink? 
You could win a Tablet PC. Get a free Tablet PC hat just for playing. 
What are you waiting for?
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to