T5: Hibernate/Session question
Hello, I have an application state object(Visit) that is storing a hibernate entity object. In a page I ask for the visit.object.getchildobject.name and receive this error: [ERROR] hibernate.LazyInitializationException could not initialize proxy - the owning Session was closed org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed Can I not do this from application state objects? Thanks, --James
Re: T5: Hibernate/Session question
there are two possible solutions: first: you declare the collection for childobjects read not lazy second: you attach the parentobject to a new session and re-read the childobjects collection 2009/2/5 James Sherwood jsherw...@rgisolutions.com Hello, I have an application state object(Visit) that is storing a hibernate entity object. In a page I ask for the visit.object.getchildobject.name and receive this error: [ERROR] hibernate.LazyInitializationException could not initialize proxy - the owning Session was closed org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed Can I not do this from application state objects? Thanks, --James -- with regards Sven Homburg http://www.chenillekit.org http://tapestry5-components.googlecode.com
RE: T5: Hibernate/Session question
Thanks, I do not want to have to change the actual POJOs as I generate them using reverse eng so I think I will just do the lookup.\ Just making sure I was not doing something wrong:) --James -Original Message- From: Sven Homburg [mailto:hombu...@googlemail.com] Sent: February-05-09 2:23 PM To: Tapestry users Subject: Re: T5: Hibernate/Session question there are two possible solutions: first: you declare the collection for childobjects read not lazy second: you attach the parentobject to a new session and re-read the childobjects collection 2009/2/5 James Sherwood jsherw...@rgisolutions.com Hello, I have an application state object(Visit) that is storing a hibernate entity object. In a page I ask for the visit.object.getchildobject.name and receive this error: [ERROR] hibernate.LazyInitializationException could not initialize proxy - the owning Session was closed org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed Can I not do this from application state objects? Thanks, --James -- with regards Sven Homburg http://www.chenillekit.org http://tapestry5-components.googlecode.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate/Session question
Em Thu, 05 Feb 2009 15:59:53 -0300, James Sherwood jsherw...@rgisolutions.com escreveu: Thanks, I do not want to have to change the actual POJOs as I generate them using reverse eng so I think I will just do the lookup.\ One solution is to call session.lock(object, LockMode.NONE) before reading any property values. It associates the object with the given session, thus avoiding the LazyInstantiationException's. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: T5: Hibernate/Session question
Hello, I used session.update(Object) and it worked, is there any difference? --James -Original Message- From: Thiago H. de Paula Figueiredo [mailto:thiag...@gmail.com] Sent: February-05-09 4:48 PM To: Tapestry users Subject: Re: T5: Hibernate/Session question Em Thu, 05 Feb 2009 15:59:53 -0300, James Sherwood jsherw...@rgisolutions.com escreveu: Thanks, I do not want to have to change the actual POJOs as I generate them using reverse eng so I think I will just do the lookup.\ One solution is to call session.lock(object, LockMode.NONE) before reading any property values. It associates the object with the given session, thus avoiding the LazyInstantiationException's. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate/Session question
Em Thu, 05 Feb 2009 16:58:39 -0300, James Sherwood jsherw...@rgisolutions.com escreveu: Hello, Hi! I used session.update(Object) and it worked, is there any difference? session.update(Object) writes the object to the database, session.lock() not. Both associate the object to the session, so use one or the other depending on what you need. :) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate/Session question
i prefer you to use the session.refresh 2009/2/5 James Sherwood jsherw...@rgisolutions.com Hello, I used session.update(Object) and it worked, is there any difference? --James -Original Message- From: Thiago H. de Paula Figueiredo [mailto:thiag...@gmail.com] Sent: February-05-09 4:48 PM To: Tapestry users Subject: Re: T5: Hibernate/Session question Em Thu, 05 Feb 2009 15:59:53 -0300, James Sherwood jsherw...@rgisolutions.com escreveu: Thanks, I do not want to have to change the actual POJOs as I generate them using reverse eng so I think I will just do the lookup.\ One solution is to call session.lock(object, LockMode.NONE) before reading any property values. It associates the object with the given session, thus avoiding the LazyInstantiationException's. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- with regards Sven Homburg http://www.chenillekit.org http://tapestry5-components.googlecode.com
Re: T5: Hibernate/Session question
Em Thu, 05 Feb 2009 17:07:24 -0300, Sven Homburg hombu...@googlemail.com escreveu: i prefer you to use the session.refresh This will overwrite your object, and sometimes you want it unchanged. As always, the best option depends on the context. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5: Hibernate/Session question
ok ;-) 2009/2/5 Thiago H. de Paula Figueiredo thiag...@gmail.com Em Thu, 05 Feb 2009 17:07:24 -0300, Sven Homburg hombu...@googlemail.com escreveu: i prefer you to use the session.refresh This will overwrite your object, and sometimes you want it unchanged. As always, the best option depends on the context. ;) -- Thiago H. de Paula Figueiredo Independent Java consultant, developer, and instructor http://www.arsmachina.com.br/thiago - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- with regards Sven Homburg http://www.chenillekit.org http://tapestry5-components.googlecode.com