facebook

Problem with XDoclet while generating Hibernate mapping fil

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #280929 Reply

    piokoch
    Member

    I have the following problem with the file Hibernate mapping file generated by XDoclet in MyEclipse IDE v. 6.0.1.

    I have two classes:

    package test;
    
    import java.util.HashSet;
    import java.util.Set;
    
    
    /**
     * 
     * @hibernate.class 
     */
    public class Address {
        private Long addressId;
        private String street;
        private String city;
        private Set persons = new HashSet();
        
    
        public Address() {
        }
        
        public Address(String street, String city) {
            this.street = street;
            this.city = city;
        }
    
        /**
         * @hibernate.set inverse = "true"
         * @hibernate.collection-key column = "addressId" 
         * @hibernate.collection-one-to-many class = "test.Person" 
         * 
         */
        public Set getPersons() {
            return persons;
        }
    
        public void setPersons(Set persons) {
            this.persons = persons;
        }
    
        /**
         * @hibernate.id generator-class = "native"
         */
        public Long getAddressId() {
            return addressId;
        }
    
        private void setAddressId(Long id) {
            this.addressId = id;
        }
    
        /**
         * @hibernate.property 
         */
        public String getCity() {
            return city;
        }
    
        public void setCity(String city) {
            this.city = city;
        }
        
        /**
         * @hibernate.property 
         */
        public String getStreet() {
            return street;
        }
    
        public void setStreet(String street) {
            this.street = street;
        }
    }

    and

    package test;
    
    
    /**
     * 
     * @hibernate.class table = "Person"
     * 
     */
    public class Person {
        private Long personId;
        private String name;
        private Address address;
    
        public Person() {
        }
    
        public Person(String name, Address address) {
            this.name = name;
            this.address = address;
        }
    
        /**
         * 
         * @hibernate.many-to-one column = "addressId" not-null = "true"
         */
        public Address getAddress() {
            return address;
        }
    
        public void setAddress(Address address) {
            this.address = address;
        }
    
    
        /**
         * @hibernate.id generator-class = "native"
         */
        public Long getPersonId() {
            return personId;
        }
    
        private void setPersonId(Long id) {
            this.personId = id;
        }
        
        /**
         * @hibernate.property 
         */
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    }

    I try to use MyEclipse to generate mapping file for them. The mapping file Person.hbm.xml is correct:

    <?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="test.Person" table="Person">
    
            <id name="personId" column="personId" type="java.lang.Long">
                <generator class="native">
                </generator>
            </id>
    
            <many-to-one name="address" class="test.Address" cascade="none"
                outer-join="auto" column="addressId" not-null="true" />
    
            <property name="name" type="java.lang.String" column="name" />
    
        </class>
    
    </hibernate-mapping>

    but the file Address.hbm.xml is broken:

    <?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="test.Address">
            <id name="addressId" column="addressId" type="java.lang.Long">
                <generator class="native">
                </generator>
            </id>
            <set role="persons" lazy="false" readonly="false" inverse="true"
                cascade="none" sort="unsorted">
    
                <key column="addressId"></key>
    
                <one-to-many class="test.Person" />
    
            </set>
            <property name="city" type="java.lang.String" column="city" />
            <property name="street" type="java.lang.String" column="street" />
        </class>
    
    </hibernate-mapping>
    <set role="persons" lazy="false" readonly="false" ...>

    cannot have attributes role and readonly, but it should have property name=”persons”.

    I managed to generate proper mapping files using XDoclet libraries and Ant task, so there is some problem with MyEclipse I think. Any ideas?

    I am using MyIDE 6.0.1, Java SDK 1.5 on Windows.

    #281021 Reply

    Loyal Water
    Member

    piokoch,
    Can you send me a sample project that would help me reproduce this issue at my end as well. You can hit the pm button at the bottom of my post and send me the project.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Problem with XDoclet while generating Hibernate mapping fil

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