Incorrect HBM mappings when using mapped superclass in inheritance graphics for ColdFusion 9.0.1. Fix 2

Let's say I have an inheritance graph where the base class extends the mapped superclass:

component name="Entity" mappedSuperClass="true"
{
    property name="CreatedOn";
}

component name="Pet" extends="Entity" table="Pet" discriminatorcolumn="pet_type"
{
    property name="PetId" fieldtype="id" generator="native";
    property name="Name";
}

component name="Dog" extends="Pet" table="Pet" discriminatorvalue="Dog"
{
    property name="FavoriteFood";
}

component name="Cat" extends="Pet" table="Pet" discriminatorvalue="Cat"
{
    property name="FavoriteSleepingSpot";
}

      

In this case, I have a base class Pet

with two subclasses Dog

and Cat

. Pet

also extends Entity

to provide some auditing properties.

In ColdFusion 9.0.1 and ColdFusion 9.0.1 Hotfix 1, these components display correctly. I tested it by dropping the HBM mapping. However, in ColdFusion 9.0.1 HotFix 2, the mappings are incorrect. For example, the display Cat

should be:

<hibernate-mapping>
    <subclass discriminator-value="Cat"
        entity-name="Cat" extends="cfc:model.Pet"
        lazy="true" name="cfc:model.Cat">
        <property name="FavoriteSleepingSpot" type="string">
            <column name="FAVORITE_SLEEPING_SPOT"/>
        </property>
    </subclass>
</hibernate-mapping>

      

But what is actually generated is the following:

<hibernate-mapping>
    <subclass discriminator-value="Cat"
        entity-name="Cat" extends="cfc:model.Pet"
        lazy="true" name="cfc:model.Cat">
        <property name="FavoriteSleepingSpot" type="string">
            <column name="FAVORITE_SLEEPING_SPOT"/>
        </property>
        <property name="CreatedOn" type="timestamp">
            <column name="CREATED_ON"/>
        </property>
    </subclass>
</hibernate-mapping>

      

In other words, subclassing includes CreatedOn

in the class Entity

when it shouldn't, and this understandably results in the following error:

Duplicate column in mapping for object: Cat column: CREATED_ON (must be mapped to insert = "false" update = "false")

My question is , is there something wrong with how my entities are declared? Or have I stumbled upon a bug in Hotfix 2 ? If so, what would be the fix for him?

The workaround I'm currently using is to dump the HBM files and edit them manually to remove the duplicate property mapping. This works fine, but I have to repeat this process every time the entities change. Unfortunately we cannot go back to fix 1 either because we need some fixes in Hotfix 2.

+2


source to share





All Articles