Hi
I try to make a basic item system, i have one table where are stored all items template and another where are stored instancied item template (called owned objects).
It look like that :
To be clear i want in my database two tables,
The first table is called Object, this table is used to store the generalisation with a table-per-class-hierarchy. This table stores all templates (objects, weapon and armor).
The second table is called OwnedObject and must store all owned objects (each owned object include some extra fields and one template).
The database structure look like:
A classic mapping file like that persist the template stored inside the owned object in the table Object but in my case it is not good because players must be able to change thir item condition, inventorySlot or even the damage of their item without change anything in the template table.
Classic mapping, not good in my case :
Code:
<class name="App.Object" table="`Object`">
<id name="ObjectID" column="`ObjectID`">
<generator class="native" />
</id>
<property name="Name"/>
<property name="Condition"/>
<subclass name="App.Weapon">
<property name="Damage" column="Damage" />
</subclass>
<subclass name="App.Armor">
<property name="Absorbtion" column="Absorbtion" />
</subclass>
</class>
<class name="App.OwnedObject" table="`OwnedObject`">
<id name="OwnedObjectID" column="`OwnedObjectID`">
<generator class="native" />
</id>
<property name="InventorySlot"/>
<property name="CrafterName"/>
<many-to-one name="Object" unique="true" class="App.Object"/>
</class>
With this mapping the database table OwnedObject does not store the template (Object) but only its primary key.
To resume my problem is the many-to-one relation not persist the template in the OwnedObject table, it just make a link to the Object table. Does it exist a way to solve my problem with a many-to-one, or does the <component> tag can be used with a class witch is itself used to make a generalisation by another class.
Thanks for your help and sorry for my bad english.