facebook

Hibernate-Xdoclet version field problems

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #232101 Reply

    rcaballeron
    Member

    Hello guys,

    I’m executing Xdoclet against a very simple class and I’ve found two errors during the generation of the mapping file.

    The first was related with the “type” attributo in the “id” element. For some reason, xdoclet claims if you specified it, in my case along the “generator-class=sequence”.

    Now, I have another different. This time myeclipse claims against the mandatory use of the “access” and “unsaved-value” of the “version” element. What it’s astonished is the fact these attributes are present in the mapping file.

    
            <version
                name="version"
                type="integer"
                column="VERSION"
                access="property"
                unsaved-value="null"            
            />
    
      2 Attribute “access” must be declared for element type “version”. Role.hbm.xml
      2 Attribute “unsaved-value” must be declared for element type “version”. Role.hbm.xml

    If I remove these two attributes the errors disappear from the problems console, but they are mandatory indeed.

    Any idea?

    TIA,

    Roque

    – System Setup ——————————-
    Operating System and version: W2K
    Eclipse version: 3.0.2
    Fresh Eclipse install (y/n): y
    If not, was it upgraded to its current version using the update manager?
    MyEclipse version: 4.0 M2
    Eclipse JDK version: 1.4.2
    – Message Body ——————————-

    #232116 Reply

    Riyad Kalla
    Member

    1) What does the class look like?
    2) Where are the errors? In the XDoclet console when you run it?

    #232123 Reply

    rcaballeron
    Member

    In the first problem the error appeared on the Xdoclet console, the second appear in the eclipse editor. You know, with red marks and in the problems window as well.

    I’m was testing a little and I think is something related with the Hibernate DTD used in the mapping xml. Is it possible to chose a different one?

    By the way, is it possible to chose a output directory for the mapping files?

    /*
     *
     * Created Wed Jun 29 10:15:51 CEST 2005 by MyEclipse Hibernate Tool.
     */
    package com.bbvasuiza.usermgmt.persistence.hibernate.domain;
    
    import java.io.Serializable;
    
    /**
     * A class that represents a row in the ROLES table.
     *
     * @hibernate.class 
     *  table="ROLES"
     *  optimistic-lock="version"  
     */
    public class Role implements Serializable {
        /**
         * The cached hash code value for this instance. Settting to 0 triggers
         * re-calculation.
         */
        private int hashValue = 0;
    
        /** The composite primary key value. */
        private java.lang.Integer roleId;
    
        /** The value of the usersRolesLnkSet one-to-many association. */
        private java.util.Set usersRolesLnkSet;
    
        /** The value of the simple name property. */
        private java.lang.String name;
    
        /** The value of the simple shortDesc property. */
        private java.lang.String shortDesc;
    
        /** The value of the simple largeDesc property. */
        private java.lang.String largeDesc;
    
        /** The value of the simple version property. */
        private java.lang.Integer version;
    
        /**
         * Simple constructor of AbstractRoles instances.
         */
        public Role() {
        }
    
        /**
         * Constructor of AbstractRoles instances given a simple primary key.
         * 
         * @param roleId
         */
        public Role(java.lang.Integer roleId) {
            this.setRoleId(roleId);
        }
    
        /**
         * Return the simple primary key value that identifies this object.
         * 
         * @return java.lang.Integer
         * 
         * @hibernate.id
         *     column="ROLE_ID"
         *     unsaved-value="null"
         *     generator-class="sequence"
         *         
         * @hibernate.generator-param
         *     name="sequence"
         *     value="ROLE_SEQ"
         *         
         */
        public java.lang.Integer getRoleId() {
            return roleId;
        }
    
        /**
         * Set the simple primary key value that identifies this object.
         * 
         * @param roleId
         */
        public void setRoleId(java.lang.Integer roleId) {
            this.hashValue = 0;
            this.roleId = roleId;
        }
    
        /**
         * Return the value of the NAME column.
         * 
         * @return java.lang.String
         * 
         * @hibernate.property
         *     column="NAME"
         *     type="string"
         *     not-null="false"
         *     unique="true"
         */
        public java.lang.String getName() {
            return this.name;
        }
    
        /**
         * Set the value of the NAME column.
         * 
         * @param name
         */
        public void setName(java.lang.String name) {
            this.name = name;
        }
    
        /**
         * Return the value of the SHORT_DESC column.
         * 
         * @return java.lang.String
         * 
         * @hibernate.property
         *     column="SHORT_DESC"
         *     type="string"
         *     not-null="false"
         */
        public java.lang.String getShortDesc() {
            return this.shortDesc;
        }
    
        /**
         * Set the value of the SHORT_DESC column.
         * 
         * @param shortDesc
         */
        public void setShortDesc(java.lang.String shortDesc) {
            this.shortDesc = shortDesc;
        }
    
        /**
         * Return the value of the LARGE_DESC column.
         * 
         * @return java.lang.String
         * 
         * @hibernate.property
         *     column="LARGE_DESC"
         *     type="string"
         */
        public java.lang.String getLargeDesc() {
            return this.largeDesc;
        }
    
        /**
         * Set the value of the LARGE_DESC column.
         * 
         * @param largeDesc
         */
        public void setLargeDesc(java.lang.String largeDesc) {
            this.largeDesc = largeDesc;
        }
    
        /**
         * Return the value of the VERSION column.
         * 
         * @return java.lang.Integer
         * 
         * @hibernate.version
         *  column="VERSION"
         *  type="integer"     
         *     unsaved-value="null" 
         */
        public java.lang.Integer getVersion() {
            return this.version;
        }
    
        /**
         * Set the value of the VERSION column.
         * 
         * @param version
         */
        public void setVersion(java.lang.Integer version) {
            this.version = version;
        }
    
        /**
         * Return the value of the ROLE_ID collection.
         * 
         * @return UsersRolesLnk
         */
        public java.util.Set getUsersRolesLnkSet() {
            return this.usersRolesLnkSet;
        }
    
        /**
         * Set the value of the ROLE_ID collection.
         * 
         * @param usersRolesLnkSet
         */
        public void setUsersRolesLnkSet(java.util.Set usersRolesLnkSet) {
            this.usersRolesLnkSet = usersRolesLnkSet;
        }
    
        /**
         * Implementation of the equals comparison on the basis of equality of the
         * primary key values.
         * 
         * @param rhs
         * @return boolean
         */
        public boolean equals(Object rhs) {
            if (rhs == null)
                return false;
            if (!(rhs instanceof Role))
                return false;
            Role that = (Role) rhs;
            if (this.getRoleId() == null || that.getRoleId() == null)
                return false;
            return (this.getRoleId().equals(that.getRoleId()));
        }
    
        /**
         * Implementation of the hashCode method conforming to the Bloch pattern
         * with the exception of array properties (these are very unlikely primary
         * key types).
         * 
         * @return int
         */
        public int hashCode() {
            if (this.hashValue == 0) {
                int result = 17;
                int roleIdValue = this.getRoleId() == null ? 0 : this.getRoleId()
                        .hashCode();
                result = result * 37 + roleIdValue;
                this.hashValue = result;
            }
            return this.hashValue;
        }
    }
    
    #232133 Reply

    Riyad Kalla
    Member

    If you are doing this xdoclet work yourself, yet you can specify the version to use by editing the hbiernate doclet and setting the version to 2.0, 2.1 or I think 3.0 is supported as well. Also the “output” field specifies the output dir.

    If you are doing this mapping through the MyEclipse Hibernate mapper, let me know because right now as I understand it you are doing it yourself by running XDoclet against your classes.

    #232144 Reply

    rcaballeron
    Member

    I’m using the XDoclet facility instead of the Hibernate mapper because, AFAIK, the m:n relationships aren’t mapped properly.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Hibernate-Xdoclet version field problems

You must be logged in to post in the forum log in