Re: Hibernate Object and JSF Bean Design

2007-01-28 Thread stormspire

When I use OptimizeIt to check objects inside memory, I find many SQL String
inside, I doubt it is related to Hibernate.  I suspect the Hibernate object
life cycle doesn't end even a request is completed.

btw, I am using OpenSessionInView filter.



Mario Ivankovits wrote:
 
 Hi!
 Well, I work in an mid size project, approx 3000 java files and 300 jsps.
 No need for load balancing or failover, which makes things easier ;-)
   
 Oh, I forget, we directly use Hibernate Objects in our view too.
 
 
 Ciao,
 Mario
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Hibernate-Object-and-JSF-Bean-Design-tf3032608.html#a8683409
Sent from the MyFaces - Users mailing list archive at Nabble.com.



RE: Hibernate Object and JSF Bean Design

2007-01-19 Thread stormspire

Hi,
  That means action layer can't take advantage of lazy loading feature any
more if detach the hibernate object and view object.
   It's also troublesome to copy value from entity to view object one by
one, and it will decrease performance if using reflecting.
   Will this approach considered as proper way to do it?

Regards
Bruce



Beelen, Marco wrote:
 
 Hi,
 
 I would agree with your friend.
 
 Although rendering pages does become easier when using the hibernate
 proxy object in your managed-beans directly, it could cause problems
 with being detached from the HibernateSession after the RestoreView
 phase. ( Even when using the HibernateSessionInView-filter. )
 
 When we switched to 'proper' view-objects and also were able to increase
 the performance of the application by retrieve all needed properties of
 an object at once instead of loading them one-by-one.
 
 I would never use hibernate proxies again in my managed-beans.
 
 With kind regards,
   Marco Beelen
 
 
 
 
 -Original Message-
 From: stormspire [mailto:[EMAIL PROTECTED] 
 Sent: donderdag 18 januari 2007 8:22
 To: users@myfaces.apache.org
 Subject: Hibernate Object and JSF Bean Design
 
 
 Now my JSF managed Bean contains some business object which is hiberante
 object.  
 My friend told me this design is wrong, he says the managed bean should
 contain only View Object, and contents of view object is translated from
 business object.
 
 Am I really Wrong?
 
 As I use lots of lazy loading from hibernate, so I can directly call
 object
 lazily loaded for master and detail example.  Any comments?
 -- 
 View this message in context:
 http://www.nabble.com/Hibernate-Object-and-JSF-Bean-Design-tf3032608.htm
 l#a8425940
 Sent from the MyFaces - Users mailing list archive at Nabble.com.
 
 
 
 
 --
 Notice:  This e-mail message, together with any attachments, contains
 information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station,
 New Jersey, USA 08889), and/or its affiliates (which may be known
 outside the United States as Merck Frosst, Merck Sharp  Dohme or MSD
 and in Japan, as Banyu - direct contact information for affiliates is 
 available at http://www.merck.com/contact/contacts.html) that may be 
 confidential, proprietary copyrighted and/or legally privileged. It is 
 intended solely for the use of the individual or entity named on this 
 message. If you are not the intended recipient, and have received this 
 message in error, please notify us immediately by reply e-mail and then 
 delete it from your system.
 
 --
 
 

-- 
View this message in context: 
http://www.nabble.com/Hibernate-Object-and-JSF-Bean-Design-tf3032608.html#a8445639
Sent from the MyFaces - Users mailing list archive at Nabble.com.



RE: Hibernate Object and JSF Bean Design

2007-01-19 Thread stormspire

Hi,
  Right now we are using HibernateInView filter, normally won't have problem
for transactions.  However if we got some exception, the session may be lost
(haven't gone to the detail, dunno why).
  If my managed bean consists two actions, one action retrieves object,
another action update the object.  So if don't use independant view object
to store the value, the hibernate entity will still be available during
these requests, will it still held database connection for it?  If so, I
think it is not scalable.  How JBoss Seam solve it?

Regards
Bruce



Giampaolo Tomassoni-2 wrote:
 
 From: stormspire [mailto:[EMAIL PROTECTED]
 
 Now my JSF managed Bean contains some business object which is hiberante
 object.  
 My friend told me this design is wrong, he says the managed bean should
 contain only View Object, and contents of view object is translated from
 business object.
 
 Am I really Wrong?
 
 As I use lots of lazy loading from hibernate, so I can directly 
 call object
 lazily loaded for master and detail example.  Any comments?
 
 JSF beans may need to be persisted into the session object, so you may get
 problems with transaction boundaries unless you're very careful in
 handling the (de)serialization process and the Hibernate's session and
 connection.
 
 An out-of-the-shelf approach with similar results but more powerful and
 reliable for you would probably be JBoss Seam, which basicly allows direct
 visibility of business entities from JSF, while correctly handling a lot
 of the hinders which may arise with this.
 
 You may find it here: http://labs.jboss.com/portal/jbossseam . They say
 it's production. I would say it is an advanced beta. Anyway, what is the
 difference today?
 
 Cheers,
 
 Giampaolo
 
 
 -- 
 View this message in context: 
 http://www.nabble.com/Hibernate-Object-and-JSF-Bean-Design-tf30326
 08.html#a8425940
 Sent from the MyFaces - Users mailing list archive at Nabble.com.
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Hibernate-Object-and-JSF-Bean-Design-tf3032608.html#a8445701
Sent from the MyFaces - Users mailing list archive at Nabble.com.



Re: Hibernate Object and JSF Bean Design

2007-01-19 Thread David Delbecq
I don't think there is a problem with using hibernate as JSF bean.
However, the managed beans (those whose lifecycle is directly managed by
jsf) should only be beans whose role is to fetch hibernate POJOs. There
is no problem in having those hibernate objects referenced by JSF
components, as long as all your hibernate POJOs are serializable and you
use the long runing hibernate sessions (those that stays alive between
request). Just put a filter that store a disconnected hibernate session
in user session, reconnect it at each request and re-disconnect it at
end of each request.

This way, each time your hibernate POJOs are used by JSF, they are
linked to an active hibernate session.
En l'instant précis du 01/19/07 09:24, stormspire s'exprimait en ces
termes:
 Hi,
   That means action layer can't take advantage of lazy loading feature any
 more if detach the hibernate object and view object.
It's also troublesome to copy value from entity to view object one by
 one, and it will decrease performance if using reflecting.
Will this approach considered as proper way to do it?

 Regards
 Bruce



 Beelen, Marco wrote:
   
 Hi,

 I would agree with your friend.

 Although rendering pages does become easier when using the hibernate
 proxy object in your managed-beans directly, it could cause problems
 with being detached from the HibernateSession after the RestoreView
 phase. ( Even when using the HibernateSessionInView-filter. )

 When we switched to 'proper' view-objects and also were able to increase
 the performance of the application by retrieve all needed properties of
 an object at once instead of loading them one-by-one.

 I would never use hibernate proxies again in my managed-beans.

 With kind regards,
   Marco Beelen




 -Original Message-
 From: stormspire [mailto:[EMAIL PROTECTED] 
 Sent: donderdag 18 januari 2007 8:22
 To: users@myfaces.apache.org
 Subject: Hibernate Object and JSF Bean Design


 Now my JSF managed Bean contains some business object which is hiberante
 object.  
 My friend told me this design is wrong, he says the managed bean should
 contain only View Object, and contents of view object is translated from
 business object.

 Am I really Wrong?

 As I use lots of lazy loading from hibernate, so I can directly call
 object
 lazily loaded for master and detail example.  Any comments?
 -- 
 View this message in context:
 http://www.nabble.com/Hibernate-Object-and-JSF-Bean-Design-tf3032608.htm
 l#a8425940
 Sent from the MyFaces - Users mailing list archive at Nabble.com.




 --
 Notice:  This e-mail message, together with any attachments, contains
 information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station,
 New Jersey, USA 08889), and/or its affiliates (which may be known
 outside the United States as Merck Frosst, Merck Sharp  Dohme or MSD
 and in Japan, as Banyu - direct contact information for affiliates is 
 available at http://www.merck.com/contact/contacts.html) that may be 
 confidential, proprietary copyrighted and/or legally privileged. It is 
 intended solely for the use of the individual or entity named on this 
 message. If you are not the intended recipient, and have received this 
 message in error, please notify us immediately by reply e-mail and then 
 delete it from your system.

 --


 

   



Re: Hibernate Object and JSF Bean Design

2007-01-19 Thread Mario Ivankovits
Hi!

Well, I work in an mid size project, approx 3000 java files and 300 jsps.
No need for load balancing or failover, which makes things easier ;-)


We moved (or currently move) from our own persistence to hibernate with
all its problems (Lazy loading, detached objects, ...) Exceptions all
around ;-)

Then, I developed the ConversationTag which you'll find in tomahawk
sandbox which introduce a new scope to JSF - the conversation scope.
Every hibernate object
 now lives in this conversation scope which is synchronized with the
hibernate session and can span multiple requests and pages.

JBoss Seam do alot more, but the main live-saver (IMHO) is its
conversation scope which we have with our tag too.


Some people do not like it do define such things in the view, so the
latest addition is a custom scope for Spring which allows you to more
naturally deal with conversation beans, you simply have to write
scope=conversation in your spring bean configuration.
Some thoughts have to be done how to synchronize such a scope with
hibernate - well, I've done something there too, but I am still not
fully happy with it.

Ciao,
Mario



Re: Hibernate Object and JSF Bean Design

2007-01-19 Thread Mario Ivankovits
Hi!
 Well, I work in an mid size project, approx 3000 java files and 300 jsps.
 No need for load balancing or failover, which makes things easier ;-)
   
Oh, I forget, we directly use Hibernate Objects in our view too.


Ciao,
Mario



RE: Hibernate Object and JSF Bean Design

2007-01-18 Thread Giampaolo Tomassoni
From: stormspire [mailto:[EMAIL PROTECTED]
 
 Now my JSF managed Bean contains some business object which is hiberante
 object.  
 My friend told me this design is wrong, he says the managed bean should
 contain only View Object, and contents of view object is translated from
 business object.
 
 Am I really Wrong?
 
 As I use lots of lazy loading from hibernate, so I can directly 
 call object
 lazily loaded for master and detail example.  Any comments?

JSF beans may need to be persisted into the session object, so you may get 
problems with transaction boundaries unless you're very careful in handling the 
(de)serialization process and the Hibernate's session and connection.

An out-of-the-shelf approach with similar results but more powerful and 
reliable for you would probably be JBoss Seam, which basicly allows direct 
visibility of business entities from JSF, while correctly handling a lot of the 
hinders which may arise with this.

You may find it here: http://labs.jboss.com/portal/jbossseam . They say it's 
production. I would say it is an advanced beta. Anyway, what is the difference 
today?

Cheers,

Giampaolo


 -- 
 View this message in context: 
 http://www.nabble.com/Hibernate-Object-and-JSF-Bean-Design-tf30326
08.html#a8425940
Sent from the MyFaces - Users mailing list archive at Nabble.com.



Hibernate Object and JSF Bean Design

2007-01-17 Thread stormspire

Now my JSF managed Bean contains some business object which is hiberante
object.  
My friend told me this design is wrong, he says the managed bean should
contain only View Object, and contents of view object is translated from
business object.

Am I really Wrong?

As I use lots of lazy loading from hibernate, so I can directly call object
lazily loaded for master and detail example.  Any comments?
-- 
View this message in context: 
http://www.nabble.com/Hibernate-Object-and-JSF-Bean-Design-tf3032608.html#a8425940
Sent from the MyFaces - Users mailing list archive at Nabble.com.