Thank you for answering.
Judging form your answer, it seems I missed something.
What I understand I should do :
- implement a Persister for my new type of collection
- implement a UserCollectionType
- how can I use this stuff in the hbm ? Is there something I have to do for this ?
Please, correct me if I'm wrong.
In fact, my case might be simpler than this. I'd really like you to suggest me the way to do it.
I have a collection, which name is Historique which contains a Map, but does not implement java.util.Map. Historique is a kinf of Collection that gives method to deal with time line (I guess it's the correct translation).
The internal map of Historique is a SortedMap<Date, Object>, where Object can be an entity or a component, depending of the mapping (could be <Date, String> or <Date, Customer> for instance)
Historique does not implement Map, because it's not one, but internally use a Map. What I want to do is to use this utility class as a new type of collection (if it really is a new one). Can you suggest me the way to do it ?
If I had to start the whole stuff (implement a new UserCollectionType, Persister and so on), I would really appreciate you to give me a few indications to achieve it. An example would be a great gift.
Code:
class Historique{
private Map<Date, Object>
}
class Customer {
private Historique<Date, Contract>
}
class Contract {
//attributes here.
}
I could also have :
Code:
class Foo{
private Historique<Date, String>
}
Maybe a good feature would be to add a settings in the hbm that would let developer tell hibernate that a class has an attribute which is a collection, but that the collection is not directly this attribute, but an attribute in the mentionned attribute.
Example
Code:
<class name="Collectivite" table="COLLECTIVITE">
<id name="id"
type="com.dexia.sofaxis.common.hibernate.UUIDUserType"
access="field">
<column name="ID" />
<generator class="assigned" />
</id>
<property name="nom" access="field">
<column name="NOM" />
</property>
<map name="histoCtra" access="field">
<key column="ID" />
<map-key column="DATE" type="date" />
<one-to-many class="Collectivite" />
</map>
</class>
is a mapping for a standard map. What we could do is :
Code:
<class name="Customer" table="COLLECTIVITE">
<id name="id"
type="com.dexia.sofaxis.common.hibernate.UUIDUserType"
access="field">
<column name="ID" />
<generator class="assigned" />
</id>
<property name="nom" access="field">
<column name="NOM" />
</property>
<map name="histoCtra.internalMap" access="field">
<key column="ID" />
<map-key column="DATE" type="date" />
<one-to-many class="Collectivite" />
</map>
</class>
I guess this feature would allow to implement a lot of good stuff without never having to implement a UserCollectionType which is a bit tricky, wouldn't it ?
I hope you understand what I mean
Best Regards,
Dom