Hibernate plugin and private methods (Noam Gal)

"." <[email protected]> Thu, 10 Apr 2008 16:29:04 +0200
Newsgroups gmane.comp.java.xdoclet-plugins
Message-ID <4F812AAB686E62478626F47FB376C99413800CE025@MAILBOXSERVER.rf.local>
Hello again.

I almost thought I got it to work , but then I noticed I accidentaly ran the xdoclet 1.2.3 ant task instead...
So here is a simaple example of a class, and the hbm that xdoclet created for it. When I change the getValue method to private, the generated hbm does not contain the value property:

FILE xdtest.java:
============
package test;

Ppblic class xdtest {
        Integer pk;
        Integer value;

        protected xdtest() {
        }

        public xdtest(Integer value) {
                this.value = value;
        }

        /*
         * @hibernate.id generator-class="sequence" column="XD_ID"
         * @hibernate.generator-param name="sequence" value="XD_SEQUENCE"
         */
        public Integer getPk() {
                return this.pk;
        }

        private void setPk(Integer pk) {
                this.pk = pk;
        }

        /*
         * @hibernate.property column="VALUE"
         */
        public Integer getValue() {
                return this.value;
        }

        private void setValue(Integer value) {
                this.value = value;
        }
}
============

FILE: xdtest.hbm.xml:
============
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "~//Hibernate/Hibernate \Mapping DTD 3.0/?EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class table="TABLE" name="test.xdtest">
    <id name="pk" type="java.lang.Itneger" column="XD_ID">
      <generator class="sequence">
        <param name="sequence">XD_SEQUENE</param>
      </generator>
    </id>
    <property name="value" column="value" />
  </class>
</hibernate-mapping>
============

As mentioned above, changing the getValue into private, will create a similar hbm, just without the "<property name="value" column="value" />" line
My ant task is defined like this:

<target name="hibernatedoclet">
        <path id="xdoclet.classpath">
                <fileset dir="/lib">
                        <include name="/*.jar" />
                </fileset>
        </path>
        <taskdef name="xdoclet" classname="org.xdoclet.ant.XDocletTask" classpathref="xdoclet.classpath" />
        <xdoclet>
                <fileset dir="/src/java">
                        <include name="**/xdtest.java" />
                </fileset>
                <component
                        classname="org.xdoclet.plugin.hibernate.HibernateMappingPlugin"
                        destdir="d:/hib" mergedir="d:/merge" force="true" version="3.0" />
        </xdoclet>
</target>

Is there anything else I am missing?
Thanks for your help,
 Noam Gal.

-----Original Message-----
Date: Tue, 8 Apr 2008 12:28:12 -0700 (PDT)
From: Konstantin Priblouda <kpriblouda-/[email protected]>
Subject: Re: [xdoclet-plugins-interest] Hibernate plugin and private
        methods
To: xdoclet-plugins-interest-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Message-ID: <815483.37996.qm-0aFvd/[email protected]>
Content-Type: text/plain; charset=iso-8859-1


--- "." <[email protected]> wrote:

> I am trying to migrate from xdoclet 1.2.3 to 2.0.4,
> mainly for my hibernate hbm mapping files.
> Until now, xdoclet was able to see the tags I had
> over private methods, and create their info in the
> hbm. After I made the switch, I see that the new
> xdoclet does not show such a behavior. Is it on
> purpose? Is there some way I can enable
> private/protected method tagging?
>
> I know that hibernate can easily deal with a private
> get/set property on my classes, and I want to keep
> some of them that way for my own encapsulation.


I just checked,  and actual codebase definitely does
pick up private getter marked with @hibernate.property

It also looks on the fields if you like.

Can you show problematic sample?

regards,

----[ Konstantin Pribluda http://www.pribluda.de ]----------------
JTec quality components: http://www.pribluda.de/projects/









This message (including any attachments) issued by RAFAEL- ADVANCED DEFENSE SYSTEMS LTD. (hereinafter "RAFAEL") contains confidential information intended for a specific individual and purpose, may constitute information that is privileged or confidential or otherwise protected from disclosure. If you are not the intended recipient, you should contact us immediately and thereafter delete this message from your system. You are hereby notified that any disclosure, copying, dissemination, distribution or forwarding of this message, or the taking of any action based on it, is strictly prohibited. If you have received this e-mail in error, please notify us immediately by  e-mail mailto:[email protected] and completely delete or destroy any and all electronic or other copies of the original message and any attachments thereof.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

_______________________________________________
xdoclet-plugins-interest mailing list
xdoclet-plugins-interest-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-interest