You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by tubin gen <fa...@gmail.com> on 2009/08/21 01:00:07 UTC

using hibernate pojo as model instead of dto

I am wondering If it is write to use hibernate pojo entities as model
objects for wicket components , or should I create a DTO and use them as
model objects , Is there any disadvantages of using entities POJO's as model
?

Re: using hibernate pojo as model instead of dto

Posted by Fernando Wermus <fe...@gmail.com>.
The case I use DTO is when I have wizards that involves many entities or/and
some data that will become an entity but it is not the entity itself.
Besides, some types that I cannot use in wicket, or maybe yes, like JodaTime
DateTime.


On Fri, Aug 21, 2009 at 5:42 AM, Mathias Nilsson <
wicket.programmer@gmail.com> wrote:

>
> I don't know about the good design but why should you make a detached copy
> of
> an perfectly good entity? It's just more work.
>
> However, if you need to use dto for webservices or there are some cases
> when
> you need to get fields from different entities then maybe you should
> consider dto.
> --
> View this message in context:
> http://www.nabble.com/using-hibernate-pojo-as-model-instead-of-dto-tp25071549p25079082.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Fernando Wermus.

www.linkedin.com/in/fernandowermus

Re: using hibernate pojo as model instead of dto

Posted by Mathias Nilsson <wi...@gmail.com>.
I don't know about the good design but why should you make a detached copy of
an perfectly good entity? It's just more work.

However, if you need to use dto for webservices or there are some cases when
you need to get fields from different entities then maybe you should
consider dto. 
-- 
View this message in context: http://www.nabble.com/using-hibernate-pojo-as-model-instead-of-dto-tp25071549p25079082.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: using hibernate pojo as model instead of dto

Posted by Michael Mosmann <mi...@mosmann.de>.
Am Donnerstag, den 20.08.2009, 18:59 -0700 schrieb fachhoch:
> Is this is a good design or using DTO is a good desing ?

it depends.. (IMHO there are only some situations where you can see some
benefit in DTO) ..

but you have to use LoadableDetachableModels or custom Model
implementations to avoid LazyLoadingExceptions

for short:
---------------------------
request comes in
  { open session for hibernate in OSV }
  render compontent
    ask model for data
      model get it from hibernate with primary key
  render finished
    throw temporary data away
      call detach() on model
        model clears any reference to the hibernate object
  { close session for hibernate in OSV }
response goes out
---------------------------

mm:)

> 
> 
> Mathias Nilsson wrote:
> > 
> > You can use entities as models. Just use LoadableDetachableModels to avoid
> > LazyLoadingExceptions
> > 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: using hibernate pojo as model instead of dto

Posted by fachhoch <fa...@gmail.com>.
Is this is a good design or using DTO is a good desing ?



Mathias Nilsson wrote:
> 
> You can use entities as models. Just use LoadableDetachableModels to avoid
> LazyLoadingExceptions
> 

-- 
View this message in context: http://www.nabble.com/using-hibernate-pojo-as-model-instead-of-dto-tp25071549p25072993.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: using hibernate pojo as model instead of dto

Posted by Mathias Nilsson <wi...@gmail.com>.
You can use entities as models. Just use LoadableDetachableModels to avoid
LazyLoadingExceptions
-- 
View this message in context: http://www.nabble.com/using-hibernate-pojo-as-model-instead-of-dto-tp25071549p25072411.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org