Results 1 to 2 of 2
  1. #1
    Nick15 is offline Member
    Join Date
    May 2007
    Posts
    38
    Rep Power
    0

    Default xdoclet and hibernate

    Hello
    I'm searching some examples about how can I generate a composite id with the tags of the XDoclet.
    Can you help me?
    Last edited by Nick15; 06-01-2007 at 01:17 AM.

  2. #2
    Marty is offline Member
    Join Date
    May 2007
    Posts
    38
    Rep Power
    0

    Default

    Hi nick
    Java Code:
    /**
    * @hibernate.class table="table"
    */
    
    public class ClasswithCompositeId  {
    
        private ClasswithCompositeIdPk PK;
    
    
        /**
         * @hibernate.id generator-class="assigned"
         * 
         */
    
        public ClasswithCompositeIdPk getPK() {
            return this.PK;
        }
    
        public void setPK(ClasswithCompositeIdPk thePK) {
            this.PK = thePK;
    
            return;
        }
    
    }
    
    package saes.election.eligibleoption;
    
    import java.io.Serializable;
    
    import org.apache.commons.lang.builder.*;
    
    public class ClasswithCompositeIdPk implements Serializable {
    
        /**
         * The composed eligible option this role is related to
         */
        private Class1 key1;
    
        /**
         * The candidate this role is related to
         */
        private Class2 key2;
    
        /**
         * @inheritDoc
         */
        @Override
        public boolean equals(Object o) {
        
        }
    
        /**
         * @inheritDoc
         */
        @Override
        public int hashCode() {
      
        }
    
        /**
         * @hibernate.many-to-one column="key1_code" outer-join="true"
         */
    
        public Class1 getKey1() {
            return this.key1;
        }
    
        public void setCandidate(Class1 key1) {
            this.key1 = key1 ;
        }
    
        /**
         * @hibernate.many-to-one column="key2_code" outer-join="true"
         */
    
        public Clase2 getClave2() {
            return this.key2;
        }
    
        public void setCandidate(Class2 key2 ) {
            this.key2 = key2 ;
        }
    
    }
    
    
    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    
    <hibernate-mapping 
    >
    
        <class
            name="ClasswithCompositeIdPk "
            table="table"
            lazy="false"
        >
    
            <composite-id
                name="keyPK"
                class="ClasswithCompositeIdPk "
            >
    
                        <key-many-to-one
                            name="key1"
                            class="Class1"
                            column="class1_code"
                        />
    
                        <key-many-to-one
                            name="key2"
                            class="Class2"
                            column="class2_code"
                        />
            </composite-id>
    
    
            <!--
                To add non XDoclet property mappings, create a file named
                    hibernate-properties-RoleData.xml
                containing the additional properties and place it in your merge 
    dir.
            -->
    
        </class>
    
    </hibernate-mapping>
    good luck

Similar Threads

  1. Hibernate, help me
    By Nick15 in forum JDBC
    Replies: 2
    Last Post: 06-05-2008, 03:39 PM
  2. EJB generation with xdoclet tags
    By gugas in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 02-18-2008, 01:07 PM
  3. Replies: 2
    Last Post: 06-30-2007, 03:01 PM
  4. Hibernate
    By Alan in forum JDBC
    Replies: 2
    Last Post: 05-11-2007, 01:19 AM
  5. Replies: 0
    Last Post: 04-26-2007, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •