-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: hbm2ddl creating incorrect column in joined-subclass
PostPosted: Fri Sep 22, 2006 12:08 pm 
Newbie

Joined: Fri Mar 17, 2006 12:54 pm
Posts: 10
I am trying to create a generic Audit class and a generic RecordAudit subclass so that I can keep track of how my objects are manipulated. When I declare RecordAudit as a joined-subclass, the column record_id is incorrectly put on the superclass Audit table when using hbm2ddl.

I have verified this problem exists using Hibernate Tools 3.2.0.beta7

Code:
$ cat Audit.hbm.xml
<?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="Audit"
        table="nm_audit"
    >

        <id
            name="id"
            column="id"
            type="java.lang.Long"
        >
            <generator class="sequence">
                <param name="sequence">nm_audit_sequence</param>
              <!--
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-Audit.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <property
            name="date"
            type="java.util.Date"
            update="true"
            insert="true"
            column="date"
            not-null="true"
        />

        <many-to-one
            name="user"
            class="User"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="user_id"
            not-null="true"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Audit.xml
            containing the additional properties and place it in your merge dir.
        -->

        <joined-subclass
            name="RecordAudit"
            table="nm_record_audit"
        >
            <key
                column="audit_id"
            />

        <many-to-one
            name="record"
            class="Record"
            cascade="none"
            outer-join="auto"
            update="true"
            insert="true"
            column="record_id"
            not-null="true"
        />

        <joined-subclass
            name="RecordField"
            table="nm_record_field"
        >
            <key
                column="record_audit_id"
            />

        </joined-subclass>

        </joined-subclass>

    </class>

</hibernate-mapping>




nm=# \d nm_audit
                 Table "public.nm_audit"
  Column   |            Type             | Modifiers
---------------+-----------------------------+-----------
id        | bigint                      | not null
date      | timestamp without time zone | not null
user_id   | bigint                      | not null
record_id | bigint                      |
Indexes:
    "nm_audit_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
    "fkd072815bb2993bcd" FOREIGN KEY (record_id) REFERENCES nm_record(id)
    "fkd072815be6b9eb4d" FOREIGN KEY (user_id) REFERENCES nm_user(id)




nm=# \d nm_record_audit
Table "public.nm_record_audit"
  Column   |  Type  | Modifiers
---------------+--------+-----------
audit_id  | bigint | not null
record_id | bigint | not null
Indexes:
    "nm_record_audit_pkey" PRIMARY KEY, btree (audit_id)
Foreign-key constraints:
    "fka118d2d9b2993bcd" FOREIGN KEY (record_id) REFERENCES nm_record(id)
    "fka118d2d939753cc7" FOREIGN KEY (audit_id) REFERENCES nm_audit(id)





nm=# \d nm_record_field
        Table "public.nm_record_field"
     Column      |  Type  | Modifiers
---------------------+--------+-----------
record_audit_id | bigint | not null
Indexes:
    "nm_record_field_pkey" PRIMARY KEY, btree (record_audit_id)
Foreign-key constraints:
    "fk60d9217415dc360c" FOREIGN KEY (record_audit_id) REFERENCES nm_record_audit(audit_id)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.