[ http://jira.codehaus.org/browse/XDP-89?page=comments#action_44484 ] 

marc schipperheyn commented on XDP-89:
--------------------------------------

Ok,

I use version 1.0.1 of the plugins.

***********interface**********
/**
 * @hibernate.class table="Messages"
 * @hibernate.discriminator column="Subclass" type="string" length="15"
 * 
 * @author m.schipperheyn
 *
 * TODO Implement Hibernate for messages
 * Window - Preferences - Java - Code Style - Code Templates
 */
public interface Message {
        
    /**
     * @hibernate.property
     * @return
     */
    public abstract Date getDateSent();

    /**
     * @hibernate.many-to-one not-null="true" column="FromSub"
     * @return
     */
    public abstract Subscriber getFrom();

    /**
     * @hibernate.property column="Message" length="4000"
     * @return
     */
    public abstract String getMessage();

    /**
     * @hibernate.many-to-one not-null="true" column="ToSub"
     * @return Subscriber
     */
    public abstract Subscriber getTo();

    /**
     * @param newVal
     * 
     */
    public abstract void setDateSent(Date newVal);

    /**
     * @param newVal
     * 
     */
    public abstract void setFrom(Subscriber newVal);

    /**
     * @param newVal
     * @throws MessageLengthException
     */
    public abstract void setMessage(String newVal) throws 
MessageLengthException;

    /**
     * @param newVal
     * 
     */
    public abstract void setTo(Subscriber newVal);

    /**
     * @hibernate.id generator-class="native" type="java.lang.Long" 
column="MessageID" unsaved-value="null"
     * @return Long
     * @return Returns the messageID.
     */
    public abstract Long getMessageID();

    /**
     * @param messageID The messageID to set.
     */
    public abstract void setMessageID(Long messageID);
    
    /**
     * @param title
     */
    public abstract void setTitle(String title);
    
    /**
     * 
     * @return
     */
    public abstract String getTitle();
}

*********abstract class**************
public abstract class aMessage{
    public static final int MAXLENGTH = 0;
        private Long messageID;

        private String message;
        private Subscriber from;
        private Subscriber to;
        private Date dateSent = new Date();
        public aMessage(){

        }

        /**
         * 
         * @return
         */
        public Date getDateSent(){
                return dateSent;
        }
        

        /**
         * 
         * @return
         */
        public Subscriber getFrom(){
                return from;
        }

        /**
         * 
         * @return
         */
        public String getMessage(){
                return message;
        }

        /**
         * 
         * @return Subscriber
         */
        
        public Subscriber getTo(){
                return to;
        }


        /**
         * @param newVal
         * 
         */
        public void setDateSent(Date newVal){
                dateSent = newVal;
        }

        /**
         * @param newVal
         * 
         */
        public void setFrom(Subscriber newVal){
                from = newVal;
        }

        /**
         * @param newVal
         * @throws MessageLengthException
         */
        public void setMessage(String newVal) throws MessageLengthException{
            if(getMaxLength() != 0 && getMaxLength() < newVal.length()){
                throw new MessageLengthException("Message too long: " + 
messageID);
            }
                message = newVal;
        }


        /**
         * @param newVal
         * 
         */
        public void setTo(Subscriber newVal){
                to = newVal;
        }

        /**
         * 
         * @return Long
         * @return Returns the messageID.
         */
        public Long getMessageID() {
                return messageID;
        }
        /**
         * @param messageID The messageID to set.
         */
        public void setMessageID(Long messageID) {
                this.messageID = messageID;
        }
    
    /* (non-Javadoc)
     * @see nl.msw.dates4free.business.entities.Message#getMaxLength()
     */
    public static int getMaxLength() {
        return MAXLENGTH;
    }

        /**
         * @return Returns the formattedDate.
         */
        public String getFormattedDate() {
                DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, 
Config.COUNTRY);
                if(dateSent != null)
                        return df.format(dateSent);
                
                return "";
        }

}

*************concrete class****************
/**
 * @hibernate.subclass discriminator-value="LOCALMAIL"
 * @author m.schipperheyn
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class LocalMail extends aMessage implements Message{
    public static final int MAXLENGTH=4000;
        private String title;
    private boolean read = false;
    private boolean notifyWhenRead;

    /**
     * @hibernate.property column="isRead"
     * @return Returns the read.
     */
    public boolean isRead() {
        return read;
    }
    /**
     * @param read The read to set.
     */
    public void setRead(boolean read) {
        this.read = read;
    }
    
    /**
     * @hibernate.property length="255"
     * @return Returns the title.
     */
    public String getTitle() {
        return title;
    }
    /**
     * @param title The title to set.
     */
    public void setTitle(String title) {
        this.title = title;
    }
    /**
     * @hibernate.property
     * @return Returns the notifyWhenRead.
     */
    public boolean isNotifyWhenRead() {
        return notifyWhenRead;
    }
    /**
     * @param notifyWhenRead The notifyWhenRead to set.
     */
    public void setNotifyWhenRead(boolean notifyWhenRead) {
        this.notifyWhenRead = notifyWhenRead;
    }
}


*********another concrete class**********
/**
 * @hibernate.subclass discriminator-value="SMS" 
proxy="nl.msw.dates4free.business.entities.SMS"
 * @author m.schipperheyn
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class SMS extends aMessage {
    public static final int MAXLENGTH=65;
    
    public void setTitle(String title){}
    
    public String getTitle(){return null;}
}


> propertie getters specified in interface lead to double inserts of properties 
> in hbm.xml
> ----------------------------------------------------------------------------------------
>
>          Key: XDP-89
>          URL: http://jira.codehaus.org/browse/XDP-89
>      Project: XDoclet 2 Plugins
>         Type: Bug
>   Components: hibernate
>     Versions: 1.0.1
>     Reporter: marc schipperheyn
>     Assignee: Anatol Pomozov
>     Priority: Minor

>
>
> When you specify a date value in an interface 
>     /**
>      * @hibernate.property
>      * @return
>      */
>     public abstract Date getDateSent();
> and implement the interface through an abstract Class to a concrete class 
> (implementing the date property only in the abstract class), I got this 
> hbm.xml through xdoclet 2.
> <hibernate-mapping>
>   <class table="Messages" name="Message">
>     <id unsaved-value="null" name="messageID" type="java.lang.Long" 
> column="MessageID">
>       <generator class="native"/>
>     </id>
>     <discriminator type="string" column="Subclass" length="15"/>
>     <property name="dateSent"/>
>     <many-to-one column="FromSub" not-null="true" name="from"/>
>     <property name="message" length="4000" column="Message"/>
>     <many-to-one column="ToSub" not-null="true" name="to"/>
>     <subclass name="LocalMail" discriminator-value="LOCALMAIL">
>       <property name="read" column="isRead"/>
>       <property name="title" length="255"/>
>       <property name="notifyWhenRead"/>
>       <property name="dateSent"/>
>       <many-to-one column="FromSub" not-null="true" name="from"/>
>       <property name="message" length="4000" column="Message"/>
>       <many-to-one column="ToSub" not-null="true" name="to"/>
>     </subclass>
>   </class>
> </hibernate-mapping>
> note the double dateSent property. This also occurs for other property types
> Kind regards,
> Marc

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
xdoclet-plugins-interest mailing list
xdoclet-plugins-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-interest

Reply via email to