-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Blend of anemic domain objects with POJO
PostPosted: Wed May 14, 2008 8:59 am 
Newbie

Joined: Thu Jul 28, 2005 8:27 am
Posts: 7
im using hibernate pojos for persistence in my application. And im using "open session in view" pattern. So you can guess that my POJOs map straight to the UI.
Everything goes smooth as long as my UI fields map straight to my POJOs. But the problem arises when there are some complex UI fields to show. e.g. when a concatenation of several properties map to single field on UI or some calculation over a field.
Now, its obvious that some sort of customized value object layer would be involved between the POJOs and the UI.
But i need an optimized way of doing so. Some design pattern or any best practice followed by hibernate.
Another option that i had in mind was to extend custom wrapper classes with POJOs but in that case after loading a POJO i would have to go by setting all the fields of that POJO into my wrapper class.
I wonder how the hibernate guys easily claim to map there POJOs straight to UI and not discuss the counter part.
Any help in this matter would be greatly appreciated.
Im sure there are a lot of guys out there like me looking for a solution for this issue.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 9:43 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You can always use the object assembler pattern.

Which framework are you using? Struts? JSF?

The reality is, your UI won't always map directly to JavaBeans. Indeed, everything from formatting of data, to simply providing an easy set of classes to UI developers, might mean a little 'massaging' of the object model might be needed. It doesn't always make life easy, but sometimes it needs to be done.

Can you give more specifics about your problem? Maybe a simplified example?

-Cameron McKenzie

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 9:55 am 
Newbie

Joined: Thu Jul 28, 2005 8:27 am
Posts: 7
Thnx for a quick reply Cameron.
Im using JSF framework. Actually what im trying to achieve is that there is a field in databse with timestamp data type.
Now, at some points in my application i have to show only the date part of that timestamp. So for that to happen i need some sort of customized pojo, cause i cant directly map that pojo's field to the UI.
Let alone this scenerio there are a number of other points in my application where i have to show computational data on behalf of a set of properties in a pojo.
And i would like some efficient methodology to achieve this paradigm.
One more thing, i like my UI to be free of such business domain logic. It should be as loosely coupled as possible. As a matter of fact it should only concentrate on its part of the job that is displaying the provided information.
Please share your personal experience, how u managed to get over this issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.