-->
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.  [ 4 posts ] 
Author Message
 Post subject: JSF + Hibernate best practice
PostPosted: Wed Jan 06, 2010 10:54 pm 
Newbie

Joined: Wed Jan 06, 2010 10:49 pm
Posts: 3
Hello. I'm figuring out how to integrate Hibernate with JSF 2.0 and I'm curious what the best practice is, particularly for the beans.

I'm using annotations to configure both hibernate and JSF. Currently I'm constructing it so that the JSF managed beans are being persisted with hibernate, with @Transient annotations on any getters that I don't want saved.

Is this the "right" way to do it?


Top
 Profile  
 
 Post subject: Re: JSF + Hibernate best practice
PostPosted: Thu Jan 07, 2010 8:15 pm 
Newbie

Joined: Wed Jan 06, 2010 10:49 pm
Posts: 3
Another couple of questions:

When doing things like sorting lists, should I get the database to do the sorting, or should I just load it into a List and sort it using java code?

When objects contain references to other objects, should the property be a reference to an object that is automatically loaded from the database, or simply a long (or whatever) representing the database key, and I manually load the referenced object from the database?


Top
 Profile  
 
 Post subject: Re: JSF + Hibernate best practice
PostPosted: Fri Feb 05, 2010 12:44 pm 
Newbie

Joined: Wed Apr 30, 2008 10:36 am
Posts: 4
Location: Germany
Have written a blog post about putting jsf 2.0 spring 3.0.0 and hibernate 3.2.2GA together ... here is the link

http://blog.pariyani.com/?p=7

_________________
Imran Pariyani


Top
 Profile  
 
 Post subject: Re: JSF + Hibernate best practice
PostPosted: Sun Feb 07, 2010 7:36 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Quote:
or simply a long (or whatever) representing the database key


No, don't bother playing around with keys. Use object references -after all, that's what Object-Relational mapping is all about. Just make the association lazy, so you don't always load the associated object. If you do need the associated object, make sure it's loaded while a Hibernate Session and a transaction is still active.

_________________
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  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.