You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Jukka Zitting <ju...@gmail.com> on 2007/01/13 13:49:21 UTC

Re: JCR Design Pattern Question- DAO class per NS?

Hi,

On 1/11/07, Wolf Benz <eu...@gmail.com> wrote:
> I was wondering about a JCR Design Pattern:
> Would it be a good idea to, as a  Rule of Thumb, construct one DAO-
> class per NS? (namespace)
> (as opposed to one per Table or Object or ...)

I usually associate a namespace with the entire data model of an
application and map node types to the classes that manage the content.

BR,

Jukka Zitting

Re: JCR Design Pattern Question- DAO class per NS?

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 1/15/07, Wolf Benz <eu...@gmail.com> wrote:
> So is what you're saying this:
>
> 1 App ~ 1 NameSpace
> & in that NameSpace: 1 Node Type ~ 1 DAO Class (roughly) ?

Yes, roughly. :-)

> Roughy that will do I guess, unless some classes are intermingled
> enough to allow 1 DAO for 2 Node Types making more sense.

Yeah, depends on how your content structure.

In fact I usually avoid the traditional DAO pattern when working with
JCR. DAOs work well when you are accessing a relational database or
some other data store whose content model is relatively foreign from
an OO perspective. JCR gives you methods like getProperty() and
setProperty() that allow very "natural" access to underlying content
without having to use an intermediate abstraction layer.

In a MVC architecture I normally use the JCR content repository
directly as the Model without any abstraction layer on top of it. In
the View I use Node.getProperty() instead of DAO bean getters and in
the Controller I have access to the full JCR feature set. This way I
can directly leverage features like versioning or observation without
any extra mapping code.

BR,

Jukka Zitting

Re: JCR Design Pattern Question- DAO class per NS?

Posted by Wolf Benz <eu...@gmail.com>.
So is what you're saying this:

1 App ~ 1 NameSpace
& in that NameSpace: 1 Node Type ~ 1 DAO Class (roughly) ?

Roughy that will do I guess, unless some classes are intermingled  
enough to allow 1 DAO for 2 Node Types making more sense.

Wolf



On 13 Jan 2007, at 13:49, Jukka Zitting wrote:

Hi,

On 1/11/07, Wolf Benz <eu...@gmail.com> wrote:
> I was wondering about a JCR Design Pattern:
> Would it be a good idea to, as a  Rule of Thumb, construct one DAO-
> class per NS? (namespace)
> (as opposed to one per Table or Object or ...)

I usually associate a namespace with the entire data model of an
application and map node types to the classes that manage the content.

BR,

Jukka Zitting