You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-dev@incubator.apache.org by Martin Koci <ma...@aura.cz> on 2005/10/10 12:41:34 UTC

[jcr-mapping] Mapping Node.getPath() to domain objects

When inserting new object into repository on existing path new node with 
[] index is created:

Assume node /Document And Sesstings/file.txt exists:

pm.insert("/Document And Sesstings/file.txt", entity) creates new node 
with path /Document And Sesstings/file.txt[1] - that is correct.

But I want set newly inserted path on inserted entity:
entity.getPath() should return /Document And Sesstings/file.txt[1]

Is it possible? Is path to node saved in special property ?
<class-descriptor className="cz.aura.admis.domain.Document" 
jcrNodeType="admis:document" >
<field-descriptor fieldName="path" 
jcrName="PATH_PROPERTY_NAME"></field-descriptor> ???
<field-descriptor fieldName="creationDate" 
jcrName="jcr:created"></field-descriptor>
<bean-descriptor fieldName="documentStream" proxy="false" 
jcrName="jcr:content"></bean-descriptor>
</class-descriptor>

Thanks,

Martin


-- 
Mgr. Martin Kočí
---------------------------------
AURA, s.r.o.
Úvoz 499/56; 602 00 Brno
ISO 9001 certifikovaná společnost
tel./fax: +420 5 43 24 51 11
e-mail:  martin.koci@aura.cz
internet: http://www.aura.cz
         http://www.j2ee.cz
--------------------------------- 


Re: Re[2]: [jcr-mapping] Mapping Node.getPath() to domain objects

Posted by Christophe Lombart <ch...@gmail.com>.
On 10/10/05, Costin Leau <co...@gmail.com> wrote:
>
>
>
> > for describing unique identifier we can have something like that:
> > <path fieldName="path">
> > </path>
> I would differ - the path can also be viewed as being a different
> table. The path is not part of the object content so it shouldn't be
> treated as one.
> The database impose the object to have an id - a special field. Note
> that it doesn't have to be a unique id over the database - smth that
> would happen if the path is considered as part of the object.
> The most approapriate method would be to require and id from the user
> which can be generated or supplied by him/her.
> This way the developer can chose if she/he wants a long/int or a
> String UUID. Creating syntetic attributes based on an object will fail
> eventually (for example if I move the path the object identity changes
> - in the database world if I rename an object the identity is the
>
same).


In summary, we have 3 possibilities :

<class-descriptor
className="org.apache.portals.graffito.jcr.testmodel.Atomic"
jcrNodeType="nt:unstructured">
<field-descriptor fieldName="myId" jcrName="myId" id = 'true'/>
.... other field, beans and collection descriptor ...
</class-descriptor>


<class-descriptor
className="org.apache.portals.graffito.jcr.testmodel.Atomic"
jcrNodeType="nt:unstructured">
<field-descriptor fieldName="myId" jcrName="UUID" id = 'true'/>
.... other field, beans and collection descriptor ...
</class-descriptor>


<class-descriptor
className="org.apache.portals.graffito.jcr.testmodel.Atomic"
jcrNodeType="nt:unstructured">
<field-descriptor fieldName="myId" jcrName="PATH" id = 'true'
sameNameSibling="false" />
.... other field, beans and collection descriptor ...
</class-descriptor>


Is the first one is still insteresting ? because we can replace it by UUID.

Re[2]: [jcr-mapping] Mapping Node.getPath() to domain objects

Posted by Costin Leau <co...@gmail.com>.

> for describing unique identifier we can have something like that:
> <path fieldName="path">
> </path>
I would differ - the path can also be viewed as being a different
table. The path is not part of the object content so it shouldn't be
treated as one.
The database impose the object to have an id - a special field. Note
that it doesn't have to be a unique id over the database - smth that
would happen if the path is considered as part of the object.
The most approapriate method would be to require and id from the user
which can be generated or supplied by him/her.
This way the developer can chose if she/he wants a long/int or a
String UUID. Creating syntetic attributes based on an object will fail
eventually (for example if I move the path the object identity changes
- in the database world if I rename an object the identity is the
same).

-- 
Best regards,
 Costin                            mailto:costin.leau@gmail.com


Re: [jcr-mapping] Mapping Node.getPath() to domain objects

Posted by Martin Koci <ma...@aura.cz>.
Christophe Lombart wrote:

>On 10/10/05, Martin Koci <ma...@aura.cz> wrote:
>  
>
>>When inserting new object into repository on existing path new node with
>>[] index is created:
>>
>>Assume node /Document And Sesstings/file.txt exists:
>>
>>pm.insert("/Document And Sesstings/file.txt", entity) creates new node
>>with path /Document And Sesstings/file.txt[1] - that is correct.
>>
>>But I want set newly inserted path on inserted entity:
>>entity.getPath() should return /Document And Sesstings/file.txt[1]
>>
>>Is it possible?
>>    
>>
>
>
>No but I think that we have to support this feature.
>
>Is path to node saved in special property ?
>
>
>No. Costin suggest also to store the path in the mapping config file and
>have method calls like :
>
>myObject.setPath();
>pm.instert(myObject)
>  
>
I think path in repository is similar as identifier in ORM world. So if 
Hibernate has

<id name="id" column="cat_id">

</id>

for describing unique identifier we can have something like that:
<path fieldName="path">
</path>

Element can accept more attributes, for example
<path fieldName="path" sameNameSibling="false" /> says POJO cannot be 
inserted on existing node so creating name with [1] is not allowed.

><class-descriptor className="cz.aura.admis.domain.Document"
>  
>
>>jcrNodeType="admis:document" >
>><field-descriptor fieldName="path"
>>jcrName="PATH_PROPERTY_NAME"></field-descriptor> ???
>><field-descriptor fieldName="creationDate"
>>jcrName="jcr:created"></field-descriptor>
>><bean-descriptor fieldName="documentStream" proxy="false"
>>jcrName="jcr:content"></bean-descriptor>
>></class-descriptor>
>>    
>>
>
>
>
>Good suggestion.
>
>I will try to fix thoses issues this week
>Thanks
>Christophe
>
>  
>



Re: [jcr-mapping] Mapping Node.getPath() to domain objects

Posted by Christophe Lombart <ch...@gmail.com>.
On 10/10/05, Martin Koci <ma...@aura.cz> wrote:
>
> When inserting new object into repository on existing path new node with
> [] index is created:
>
> Assume node /Document And Sesstings/file.txt exists:
>
> pm.insert("/Document And Sesstings/file.txt", entity) creates new node
> with path /Document And Sesstings/file.txt[1] - that is correct.
>
> But I want set newly inserted path on inserted entity:
> entity.getPath() should return /Document And Sesstings/file.txt[1]
>
> Is it possible?


No but I think that we have to support this feature.

Is path to node saved in special property ?


No. Costin suggest also to store the path in the mapping config file and
have method calls like :

myObject.setPath();
pm.instert(myObject)

<class-descriptor className="cz.aura.admis.domain.Document"
> jcrNodeType="admis:document" >
> <field-descriptor fieldName="path"
> jcrName="PATH_PROPERTY_NAME"></field-descriptor> ???
> <field-descriptor fieldName="creationDate"
> jcrName="jcr:created"></field-descriptor>
> <bean-descriptor fieldName="documentStream" proxy="false"
> jcrName="jcr:content"></bean-descriptor>
> </class-descriptor>



Good suggestion.

I will try to fix thoses issues this week
Thanks
Christophe