Expand my Community achievements bar.

Hibernate/spring and do I really need value objects

Avatar

Former Community Member
I have an existing spring/hibernate application which uses
struts that I would like to convert to flex. I can call my remote
services ok, but the flex serializer seems to want to traverse all
objects returned. Since our service layer returns native hibernate
objects that are disconnected, flex causes
lazyinitializationexception as it traverses every getSomeCollection
on our objects. Is there some way to tell the serializer to NOT do
this? I am trying to avoid making wrappers or VO objects for these

existing services.



Thanks!
3 Replies

Avatar

Level 1
Hi,



i have as of yet not seen the possibility to restrict the
flex serializer to do what you want. But i would not advice you to
propagate your domain objects beyond the sevicelayer. This will
only add more complexity in your presentation layer (you might want
to combine multiple domain objects to a single presentation),
furthermore this exposure of your domain objects can lead to weird
behaviour in your domain when you, by mistake, alter the objects
along the way.



kind regards,



Marc

Avatar

Former Community Member

quote:




Originally posted by:
jlawmi


I have an existing spring/hibernate application which uses
struts that I would like to convert to flex. I can call my remote
services ok, but the flex serializer seems to want to traverse all
objects returned. Since our service layer returns native hibernate
objects that are disconnected, flex causes
lazyinitializationexception as it traverses every getSomeCollection
on our objects. Is there some way to tell the serializer to NOT do
this? I am trying to avoid making wrappers or VO objects for these

existing services.



Thanks!





this is a common hibernate issue. i use DTO's to get around
this.

Avatar

Level 1
hi,



As jus74 said it is common behaviour, but not only for
hibernate, but also for all similar techniques (JDO, EJB3, Toplink
etc). In my opinion you should model your VO/DTO objects according
to the needs of your interface (i.e. the fields you need in your
interface should be present in your Vo/DTO).

Then you can choose to code custom classes to convert your
VO's to your domain objects, or you can make a sightly bigger
effort and create a small framework that does the translation from
VO to domainobjects for your. i can verify for you that the latter
will save you much time in your current project and in your future
projects.



kind regards,



Marc