You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by cree <vi...@oswego.edu> on 2008/06/25 22:56:54 UTC

Struts 2 And Hibernate Problem

Hello,
 
I recently have been working on a struts 2 + spring 2 + hibernate system and
have come across a problem that I never have when just working on a struts 2
system.  

I have two action classes, one that prepares the jsp and populates some
selects for the user to choose from, and another that takes and processes
the information.  When the first action is invoked the result will bring it
to the tiles (type="tiles") on the struts.xml file.  The second action will
take the form information and do a search, in this instance I am using
hibernate to access the db.

I would do the search and when I get the list of persistent values I would
chain (type="chain") to the first action class with the list of persistent
objects and would then return to the tiles and the jsp showing the values
that I found on the search.  

The problem I am having here is that because of the chain (or similarly a
redirect action), the list of persistent objects will re-appear if I went
off to some other action classes and came back.  What I mean by that is if I
had a list of 10 values that I searched for and displayed them,  if I went
to some other jsp/action class and came back to that same one the same exact
10 values are being populated.  

At that point when I would return to the original jsp the value stack should
have removed them completely, which it has.  There is no trace of the list
of persistent objects on the value stack as well as not being a cache
problem.  The situation arises when the chain occurs, I have worked with
just a struts 2 system for a year now and never had this problem.   I  know
this is the case because when I get rid of the chain and invoke the tiles
from the second action class the problem goes away.

I am not too sure why these values persist throughout the session and why
they re-appear even though they are not on value stack.  I have found a very
similar problem in which this person found that the problem occured during
an action redirect at 
http://www.nabble.com/Struts-2-%2B-Hibernate-question-td17527841.html
http://www.nabble.com/Struts-2-%2B-Hibernate-question-td17527841.html 

On a side note, just remembered, when I would want to populate the list 
after its already been populated (so the user will search once then decide
to search again) the values wouldnt change even after setting it to a new
list.  If I set that list to null first then changed it, the values would
change,  not sure if that makes much sense.

If anyone has an idea on what can be causing this I would greatly appretiate
your help.
-- 
View this message in context: http://www.nabble.com/Struts-2-And-Hibernate-Problem-tp18121609p18121609.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And Hibernate Problem

Posted by Lukasz Lenart <lu...@googlemail.com>.
Hi,

Are you using spring to instantiate your actions? If so, did you setup
to not use singletons?


Regards
-- 
Lukasz
http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And Hibernate Problem

Posted by cree <vi...@oswego.edu>.
So I have been doing some testing and it seems the the same two action
objects are persisting.  So when I invoke the first action class the
ActionInvocation has on the stack (for lack of a better name)
PrepareTestAction@d044d9.  When I submit the form to the processing action I
get some other arbitrary action.  

When I leave the page and come to it again the same class
PrepareTestAction@d044d9 is on the value stack and is what becomes invoked. 
This would explain why the list of persistent objects is still showing. 
However in my other struts 2 environment where I am not using hibernate nor
spring there are new objects each time (PrepareTestAction@f10443c...).  

I hope this sheds some light on what can be going wrong because I can still
not find the solution. 

Thank you all.
-- 
View this message in context: http://www.nabble.com/Struts-2-And-Hibernate-Problem-tp18121609p18139584.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 And Hibernate Problem

Posted by cree <vi...@oswego.edu>.
I cannot believe I missed that, my reports showed how obviously it was
creating singletons and never configured it not to.  Thanks for the
information, resolved the problem within minutes of reading your response.  

Thanks again!
-- 
View this message in context: http://www.nabble.com/Struts-2-And-Hibernate-Problem-tp18121609p18140542.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org