6 messages in org.apache.jackrabbit.usersRe: Using Collections - OCM
FromSent OnAttachments
KaizerOct 24, 2007 4:55 am 
Christophe LombartOct 25, 2007 11:50 pm 
KaizerOct 26, 2007 12:38 am 
Christophe LombartOct 26, 2007 1:02 am 
KaizerOct 26, 2007 2:13 am 
Christophe LombartOct 26, 2007 5:16 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Using Collections - OCMActions...
From:Kaizer (Kaiz@mastek.com)
Date:Oct 26, 2007 12:38:35 am
List:org.apache.jackrabbit.users

Thanks a lot! I am using the discriminator approach. In fact i was thinking of writing my own CollectionConverter wherein I would save the object by taking the class of the item being stored rather than from the "elementClassName" attribute. But the problem would be that while retrieving the object, I wouldnt have the class name to instantiate. Thanks again!

Regards Kaizer

Christophe Lombart wrote:

Sorry for the delay I was very busy this week.

Which inheritance strategy are you using ? Are you using the a discriminator or a different node type per Class ?

There are 2 possibilities :

1/ Using a different node type per class in the hierarchy, here is a example from the unit test. The implement-descriptor is not mandatory.

<class-descriptor className="org.apache.jackrabbit.ocm.testmodel.inheritance.impl.FolderImpl" jcrType="ocm:folderimpl"

extend="org.apache.jackrabbit.ocm.testmodel.inheritance.impl.CmsObjectImpl" discriminator="false" > <implement-descriptor interfaceName="org.apache.jackrabbit.ocm.testmodel.interfaces.Folder" /> <collection-descriptor fieldName="children" proxy="true" autoUpdate="false"


elementClassName="org.apache.jackrabbit.ocm.testmodel.inheritance.impl.CmsObjectImpl"


collectionConverter="org.apache.jackrabbit.ocm.manager.collectionconverter.impl.NTCollectionConverterImpl" /> </class-descriptor >

2/ Using a discriminator (discriminator =true). It can be used when you are using the same node type for the complete class hierarchy. There is no unit tests on collection-descriptor with a discriminator. So, I will write a new unit test for this use cases and I will give some feedback. So maybe there are some bug for this kind of situation.

Again sorry for the delay.

br, Christophe

On 10/24/07, Kaizer <Kaiz@mastek.com> wrote:

Hi,

I have a class A which has a collection of objects of type B. I have made the corresponding definitions in the mapping xml. However, If i create a class C which extends B and save objects of type C in the list and then try to retrieve them, I always get an instance of B as the ObjectConverterImpl always creates a new instance of the "elementClassName" defined in the mapping (which would be B in this case). How can i achieve the storage and retrieval in this scenario?Would I require a custom CollectionConverter?

Thanks.

Regards Kaizer -- View this message in context: http://www.nabble.com/Using-Collections---OCM-tf4683858.html#a13384206 Sent from the Jackrabbit - Users mailing list archive at Nabble.com.