Table for class class hierarchy in sleep mode

I have the following Hibernate Mapping that needs to be mapped using a table for a class hierarchy:

<hibernate-mapping package='dao'>
    <meta attribute='class-description'></meta>
    <class name='PropertyDAO'>
        <id name='id' column='id_property'>
            <generator class='assigned'/>
        </id>
        <property name='address' column='address' type='string'/>
        <union-subclass name='HouseDAO' table='house'>
            <property name='noOfRooms' column='noOfRooms'/>
            <property name='totalArea' column='totalArea'/>
            <property name='price' column='price'/>
        </union-subclass>
        <union-subclass name='LandDAO' table='land'>
            <property name='area' column='area'/>
            <property name='unitPrice' column='unitPrice'/>
        </union-subclass>
    </class>
</hibernate-mapping>

Which means that in the database I have only two tables:

  • house (id_property (PK), address, noOfRooms, totalArea, price)
  • land (id_property (PK), address, area, unit of price)

As I understand it, in this case, identifiers should be generated explicitly before calling .save (), so my question is: how can I create a strategy for automatically creating identifiers, so that identifiers from a particular class form a continuous area when attached.

+3
source share
3 answers

, ; , . ,

0

, , , .

- , , , , , (). Iow: , PK, FK pk , - , - .

, (. Nijssen/Halpin NIAM/ORM)

+3

<key column="id"/>

This should force subclasses to use identifiers from the property table, since it depends on it. (super). A column refers to a column in a subclass that is an external reference to a super.

+1
source

All Articles