facebook

Parent/Child with 1 table

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

    Ufuk COBAN
    Member

    i have a table described below. each line can be a child of another line. i added mapping file that is generated by my eclipse. i also added the mapping file that i want it to be. what is worng with this? can i manage the way myeclipse generate mapping file? or i should change database relations? at least i need productGroupID property to be generated.

    C R EATE TABLE `product_group` (
    `product_group_id` int(10) unsigned NOT NULL auto_increment,
    `product_group_name` varchar(200) NOT NULL default ”,
    `parent_group_id` int(10) unsigned NOT NULL default ‘0’,
    `owner_id` int(10) unsigned NOT NULL default ‘0’,
    `product_category_id` int(10) unsigned NOT NULL default ‘0’,
    PRIMARY KEY (`product_group_id`),
    KEY `index_product_group_owner_id` (`owner_id`),
    KEY `index_product_group_category_id` (`product_category_id`),
    CONSTRAINT `FK_prd_product_group_2` FOREIGN KEY (`product_category_id`) REFERENCES `product_category` (`product_category_id`),
    CONSTRAINT `FK_product_group_2` FOREIGN KEY (`owner_id`) REFERENCES `user` (`user_id`),
    CONSTRAINT `FK_product_group_3` FOREIGN KEY (`product_group_id`) REFERENCES `product_group` (`product_group_id`)
    ) TYPE=InnoDB COMMENT=’InnoDB free: 10240 kB; (`product_category_id`) REFER `atmuc/’;

    ——————————————
    Myeclipse generated;

    <hibernate-mapping package=”com.atmuc.portal.product”>

    <class name=”ProductGroup” table=”product_group”>
    <id name=”productGroup” column=”product_group_id” type=”java.lang.Integer”>
    <generator class=”native”/>
    </id>

    <property name=”productGroupName” column=”product_group_name” type=”java.lang.String” not-null=”true” />
    <property name=”parentGroupId” column=”parent_group_id” type=”java.lang.Integer” not-null=”true” />

    <many-to-one name=”productCategory” column=”product_category_id” class=”ProductCategory” not-null=”true” />

    <many-to-one name=”user” column=”owner_id” class=”User” not-null=”true” />

    <set name=”productSet” inverse=”true”>
    <key column=”product_group_id”/>
    <one-to-many class=”Product”/>
    </set>

    <set name=”productGroup1Set” inverse=”true”>
    <key column=”product_group_id”/>
    <one-to-many class=”ProductGroup”/>
    </set>
    </class>

    </hibernate-mapping>

    —————————————————————-
    What i need;

    <hibernate-mapping>
    <class name=”com.atmuc.portal.product.ProductGroup”
    table=”prd_product_group” lazy=”false”>
    <id name=”productGroupID”>
    <column name=”product_group_id” sql-type=”Integer”
    not-null=”true” />
    <generator class=”native” />
    </id>
    <property name=”productGroup” column=”product_group”
    not-null=”true” />
    <property name=”parentGroupID” column=”parent_group_id”
    not-null=”true” />
    <many-to-one name=”owner” class=”com.atmuc.portal.user.User”
    unique=”true” not-null=”true” column=”owner_id” />
    <!– many-to-one name=”parentGroup”
    class=”com.atmuc.portal.product.ProductGroup” unique=”true”
    insert=”false” update=”false” not-null=”true”
    column=”parent_group_id” /–>
    <many-to-one name=”productCategory”
    class=”com.atmuc.portal.product.ProductCategory” unique=”true”
    not-null=”true” column=”product_category_id” />
    <set name=”childProductGroups” table=”prd_product_group”>
    <key column=”parent_group_id” not-null=”false”/>
    <one-to-many class=”com.atmuc.portal.product.ProductGroup” />
    </set>
    </class>
    </hibernate-mapping>

    #236168 Reply

    Riyad Kalla
    Member

    For the time being if you need more control over your mappings (until we have the visual mapper ready) you can fall back on XDoclet or continue to manually modify the generated mapping files. The mapping files are generated with the more general cases so as to work in the broadest setups, however in cases where you need more fine tuned control therei s a little more elbow work.

    #236569 Reply

    tleung
    Member

    I am having the same problem. What is the target release date for the visual mapper? I can manually make the adjustment in the mean time. Thanks.

    #236618 Reply

    Riyad Kalla
    Member

    We are shooting for 5.0

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Parent/Child with 1 table

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