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.  [ 8 posts ] 
Author Message
 Post subject: aim of UserCollectionType
PostPosted: Thu Oct 12, 2006 11:38 am 
Newbie

Joined: Tue Oct 10, 2006 10:36 am
Posts: 7
I'm desesperatly trying to implement a custom Collection, and arrived to the following conclusion :

UserCollectionType is only aimed at letting us to use a specific implementation of a standard java collection framework. What I want is to give an implementation of my specific collection.

Can someone confirm this ? If not, I relaly would appreciate someone to explain me how to achieve it.

Regards,

Dom


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 12, 2006 12:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no, UserCollectionType can be used to implement support for any type of collection.

Subclasses of java collection framework is of course simpler since there already are persisters for them....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 13, 2006 3:24 am 
Newbie

Joined: Tue Oct 10, 2006 10:36 am
Posts: 7
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 5:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
there is an example of usercollectiontype in the unit test.

and yes, you will have to customize an existing persister or write your own to handle collections that does not implement java 2 collection api's.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 11:10 am 
Newbie

Joined: Tue Oct 10, 2006 10:36 am
Posts: 7
After many head aches, I finally understood that my TimeLine class has to be treated as a component.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 11:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh what?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 12:00 pm 
Newbie

Joined: Tue Oct 10, 2006 10:36 am
Posts: 7
and that I really didn't have to go so far (usertype, ...). I just had to see my Historique class as a component with a Map inside.


Top
 Profile  
 
 Post subject: Followup on the userCollectionType
PostPosted: Mon Jul 23, 2007 2:51 pm 
Newbie

Joined: Fri Jul 13, 2007 4:41 pm
Posts: 6
max wrote:
eh what?


Max, do you you on how to do the annotation of the uer collection type? thanks


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

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.