You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com> on 2011/06/03 04:56:56 UTC

setReuseItems(true) + transactions = ERROR

Hello, 

I used to refresh all the components in the listview for each http
transaction.

But now I tried to use the:

setReuseItems(true); 

When using a ListView. Documentation says that is a must (but I made it
to work without it).

The problem is that now the objects are serialized and deserialized and
not loaded from database in each http transaction. Result is that I
always get the following error:

Row was updated or deleted by another transaction (or unsaved-value
mapping was incorrect)


How can I avoid this error and use the setReuseItems(true)?

Thank you in advance.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setReuseItems(true) + transactions = ERROR

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
Hi James, 

I added it already:
-----------------------------
	<filter>
		<filter-name>openSessionInViewFilter</filter-name>

<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
		<init-param>
			<param-name>singleSession</param-name>
			<param-value>true</param-value>
		</init-param>
		<init-param>
			<param-name>sessionFactoryBeanName</param-name>
			<param-value>opCustomerSessionFactory</param-value>
		</init-param>
	</filter>

...



	<filter-mapping>
		<filter-name>BasicFormApplication</filter-name>
		<url-pattern>/basicform/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
	</filter-mapping>
	<filter-mapping>
		<filter-name>openSessionInViewFilter</filter-name>
		<url-pattern>/basicform/*</url-pattern>
		<dispatcher>REQUEST</dispatcher>
		<dispatcher>INCLUDE</dispatcher>
		<dispatcher>FORWARD</dispatcher>
	</filter-mapping>
-------------------------------------------

But it has something to do with transactions because the session is
opened. 

It's strange. It used to work... But something I changed made it to
broke. I even saved some objects before contacting you... hehehehe

I messed it up! :D

Any directions on this?


        


"No subestimes el poder de la gente estúpida en grupos grandes" 

El vie, 03-06-2011 a las 13:59 -0400, James Carman escribió:
> Try using the open session in view filter


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setReuseItems(true) + transactions = ERROR

Posted by James Carman <jc...@carmanconsulting.com>.
Try using the open session in view filter
On Jun 3, 2011 1:55 PM, "Gonzalo Aguilar Delgado" <
gaguilar@aguilardelgado.com> wrote:
> Hi Again,
>
> I checked why I'm receiving this nasty error. It seems that fails in
> this piece of code of the submit form:
>
> @Override
> protected void onSubmit() {
> log.debug("Saving content");
> IModel model = this.getDefaultModel();
> Lead object = (Lead)model.getObject();
> if(leadDAO!=null && object!=null)
> {
> ------>Is not attached if(leadDAO.isAttached(object))
> leadDAO.save(object);
> }
> super.onSubmit();
> }
>
> That's strange because behind there is a LoadableDetachableModel that
> loads this object. If it's loaded in the submit it MUST be same
> transaction that loaded it. Maybe it opened another one?
>
> Anyway it must be attached because nothing happened in the middle. But
> is not.
>
> Why? Is this normal?
>
> I suppose that normal execution is:
>
> * Submit is performed.
> * load() method of the model is executed because transient object is
> lost on this new http session.
> * object loaded is sent to the CompoundPropertyModel that encloses it.
> * The object is updated by the CompoundPropertyModel model.
> * onSubmit() is executed
> * getObject() does not executes load() function of the
> LoadableDetachableModel because it already was loaded.
>
> Here comes the question... So then, Why it's not attached? Who oppened a
> new transaction? Why?
>
> LOGS
> -------------------------
> When onSubmit logs shows as follows:
> DEBUG - Collections - Collection found:
>
[com.level2.enterprise.hibernate.generated.Lead.leadIdentifiers#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7],
was:
[com.level2.enterprise.hibernate.generated.Lead.leadIdentifiers#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7]
(uninitialized)
> DEBUG - Collections - Collection found:
>
[com.level2.enterprise.hibernate.generated.Lead.leadBasicDetails#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7],
was:
[com.level2.enterprise.hibernate.generated.Lead.leadBasicDetails#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7]
(uninitialized)
> DEBUG - tractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0
> deletions to 1 objects
> DEBUG - tractFlushingEventListener - Flushed: 0 (re)creations, 0
> updates, 0 removals to 2 collections
> DEBUG - Printer - listing entities:
> DEBUG - Printer -
> com.level2.enterprise.hibernate.generated.Lead{dateLead=2009-04-03
> 00:00:00, leadBasicDetails=<uninitialized>, email=test@test.com,
> dateCreated=2009-11-05 00:00:00, leadIdentifiers=<uninitialized>,
> idLot=132,
> uuid=com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7,
dateUpdated=2011-04-27 20:52:15}
> DEBUG - JDBCTransaction - re-enabling autocommit
> DEBUG - JDBCTransaction - committed JDBC Connection
> DEBUG - ConnectionManager - transaction completed on session
> with on_close connection release mode; be sure to close the session to
> release JDBC resources!
> DEBUG - ibernateTransactionManager - Closing Hibernate Session
> [org.hibernate.impl.SessionImpl@5ce0f945] after transaction
> DEBUG - SessionFactoryUtils - Closing Hibernate Session
> DEBUG - ConnectionManager - releasing JDBC connection [ (open
> PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
> DEBUG - ConnectionManager - transaction completed on session
> with on_close connection release mode; be sure to close the session to
> release JDBC resources!
> --------------------------------------------------
> There's one transaction completed. I suppose the one that loaded it.
>
> The isAttached created a new transaction:
> --------------------------------------------------
> DEBUG - ScaffoldingForm - Saving content
> DEBUG - ibernateTransactionManager - Creating new transaction with name
> [com.googlecode.genericdao.dao.hibernate.GenericDAO.isAttached]:
> PROPAGATION_REQUIRED,ISOLATION_DEFAULT
> DEBUG - SessionImpl - opened session at timestamp:
> 13071235926
> DEBUG - ibernateTransactionManager - Opened new Session
> [org.hibernate.impl.SessionImpl@145edcf5] for Hibernate transaction
> DEBUG - ibernateTransactionManager - Preparing JDBC Connection of
> Hibernate Session [org.hibernate.impl.SessionImpl@145edcf5]
> DEBUG - JDBCTransaction - begin
> DEBUG - ConnectionManager - opening JDBC connection
> DEBUG - JDBCTransaction - current autocommit status: true
> DEBUG - JDBCTransaction - disabling autocommit
> DEBUG - ibernateTransactionManager - Exposing Hibernate transaction as
> JDBC transaction [jdbc:postgresql://127.0.0.1:5432/op_development_es,
> UserName=user_development, PostgreSQL Native Driver]
> DEBUG - ibernateTransactionManager - Initiating transaction commit
> DEBUG - ibernateTransactionManager - Committing Hibernate transaction on
> Session [org.hibernate.impl.SessionImpl@145edcf5]
> DEBUG - JDBCTransaction - commit
> DEBUG - JDBCTransaction - re-enabling autocommit
> DEBUG - JDBCTransaction - committed JDBC Connection
> DEBUG - ConnectionManager - transaction completed on session
> with on_close connection release mode; be sure to close the session to
> release JDBC resources!
> DEBUG - ibernateTransactionManager - Closing Hibernate Session
> [org.hibernate.impl.SessionImpl@145edcf5] after transaction
> DEBUG - SessionFactoryUtils - Closing Hibernate Session
> DEBUG - ConnectionManager - releasing JDBC connection [ (open
> PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
> DEBUG - ConnectionManager - transaction completed on session
> with on_close connection release mode; be sure to close the session to
> release JDBC resources!
> --------------------------------------------
>
> Why? Because on the new transaction it will not be attached so I cannot
> save it. I suppose it must continue with the same transaction that
> loaded it.
>
>
>
> Thank you in advance.
>
>
>
>
>
>
> "No subestimes el poder de la gente estúpida en grupos grandes"
>
> El vie, 03-06-2011 a las 09:26 +0200, Gonzalo Aguilar Delgado escribió:
>> Hi Sven,
>>
>> Thank you for the update. I will check why they are not detached... They
>> should.
>>
>> Tnx again.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

Re: setReuseItems(true) + transactions = ERROR (Solved!)

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
Without transactions it works now. With few implications.

	1.- I have to put singleSession to true. Otherwise it fails:
	<filter>
		<filter-name>openSessionInViewFilter</filter-name>

<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
		<init-param>
			<param-name>singleSession</param-name>
			<param-value>true</param-value>
		</init-param>
		<init-param>
			<param-name>sessionFactoryBeanName</param-name>
			<param-value>opCustomerSessionFactory</param-value>
		</init-param>
	</filter>


	2.- I have to flush manually the session after saving. Because if I
don't do it database got not updated. Any directions here? Seems to be
normal as there are no transaction delimiters. But should be normal to
flush database when session ends. 
	Unfortunately the object got reloaded from the database before it
happens because it must be shown again in the form. I think because of
this the object returns to the previous values. But I don't know if this
is normal. 

Anyway this works:
			@Override
			protected void onSubmit() {
				log.debug("Saving content");
				IModel model = this.getDefaultModel();
				Lead object = (Lead)model.getObject();
				if(leadDAO!=null && object!=null)
				{
						leadDAO.save(object);
						leadDAO.flush();

				}
				
			}
			
		};


Hope it helps someone.


El sáb, 04-06-2011 a las 14:31 +0200, Gonzalo Aguilar Delgado escribió:
> Oh man... It's almost solved but a lot of things happened in the middle:
> 
>         1.- I was using wicket examples configurations that makes no use
>         of the org.apache.wicket.spring.SpringWebApplicationFactory in
>         the WicketFilter. I normally use it but for this project wanted
>         to stick to wicket example pages format. Solved problem 1 ->
>         change filter definition.
>         
>         2.- wicket exampled had lots of libraries inside WEB-INF/lib. I
>         didn't realized of this and everything got mixed. Different
>         libraries, different versions all different. Solved problem 2 ->
>         remove libraries and add dependencies to maven.
>         
>         3.- Filters!!! The order of the filters does matter. :D the OSIV
>         MUST be mapped before the wicket filter. I thought that I knew
>         this but did it wrooong. Solved problem 3 -> put OSIV before any
>         other filter.
>         
>         
> With this everything backs to work. The only problem that I have to
> check now are transactions, and the order of doing things. Now object
> got loaded after model updates and it lost changes before saving. But
> the actual saving works. 
> 
> 
> Thank you all guys!!! 
> 
> Hope this e-mail serves as reference to others... :D
> 
> 
> 
> 
> 
> 
> 
> 
> El sáb, 04-06-2011 a las 07:27 -0400, James Carman escribió:
> > Can you try to replicate what you're doing in a more simple fashion?
> > Take your wicket framework code out of the mix.  Just try a
> > wicket/spring/hibernate example.  You can use the Wicketopia example
> > as a template if you want.
> > 
> > On Sat, Jun 4, 2011 at 6:01 AM, Gonzalo Aguilar Delgado
> > <ga...@aguilardelgado.com> wrote:
> > > I removed transactional pointcuts to see if this removes the issue.
> > >
> > > But the problem got worse. It seems that something is really wrong
> > > configured in my project.
> > >
> > > DEBUG - DefaultListableBeanFactory - Returning cached instance of
> > > singleton bean 'leadDAOBean'
> > > DEBUG - SessionFactoryUtils        - Opening Hibernate Session
> > > DEBUG - SessionImpl                - opened session at timestamp:
> > > 13071814596
> > > DEBUG - SessionFactoryUtils        - Closing Hibernate Session
> > > ERROR - RequestCycle               - Can't instantiate page using
> > > constructor public
> > > org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()
> > > org.apache.wicket.WicketRuntimeException: Can't instantiate page using
> > > constructor public
> > > org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()
> > >
> > > Watch this:
> > >  SessionFactoryUtils        - Opening Hibernate Session
> > >
> > > It seems that is not the OSIV filter. It's hibernate who opens the
> > > session. Why?
> > >
> > > It's strange because OSIV is configured:
> > > DEBUG - OpenSessionInViewFilter    - Initializing filter
> > > 'openSessionInViewFilter'
> > > DEBUG - OpenSessionInViewFilter    - Filter 'openSessionInViewFilter'
> > > configured successfully
> > >
> > > And the problem got worse without transactions:
> > >
> > > WicketMessage: Can't instantiate page using constructor public
> > > org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()
> > >
> > > Root cause:
> > >
> > > org.hibernate.HibernateException: No Hibernate Session bound to thread,
> > > and configuration does not allow creation of non-transactional one here
> > >
> > > Not even the first page is instantiated...
> > >
> > > Will search more...
> > >
> > >
> > >
> > >
> > >
> > > El sáb, 04-06-2011 a las 11:28 +0200, Gonzalo Aguilar Delgado escribió:
> > >> >Hi,
> > >> >are you sure your model is a LDM?
> > >>
> > >> Yes. Sure. Encapsulated by an CompoundPropertyModel.
> > >> -------
> > >> new CompoundPropertyModel(scaffoldableModel)
> > >> -------
> > >> /*
> > >>                * Need this because wicket serializes everything and need to reload
> > >> it when
> > >>                * it's needed. This way wicket and hibernate plays well
> > >>                */
> > >>               IModel<Lead> scaffoldableModel = new
> > >> LoadableHibernateModelImpl<Lead>(getFirst())
> > >>               {
> > >>                       /**
> > >>                        *
> > >>                        */
> > >>                       private static final long serialVersionUID = 1L;
> > >>                       @SpringBean(name = "leadDAOBean")
> > >>                       private LeadDAO leadDAO;
> > >>                       private UuidUserType uuid;
> > >>
> > >>                       @Override
> > >>                       protected Lead load() {
> > >>                               Lead lead = null;
> > >>                               if(uuid!=null)
> > >>                               {
> > >>                                       lead = leadDAO.find(uuid);
> > >>
> > >>                               }
> > >>                               return lead;
> > >>                       }
> > >>
> > >>                       @Override
> > >>                       protected void setNonTransientObject() {
> > >>                               Lead lead =  this.getObject();
> > >>                               if(lead!=null)
> > >>                                       uuid = lead.getUuid();
> > >>                       }
> > >>
> > >>
> > >>               };
> > >>
> > >> --------
> > >> And...
> > >> ---------
> > >> public abstract class LoadableHibernateModelImpl<T> extends
> > >> LoadableDetachableModel<T>
> > >>       implements LoadableHibernateModel<T>, IModel<T>
> > >> ---------
> > >>
> > >> detach and load got called. So it's working. The problem seems to be
> > >> transactions.
> > >>
> > >> I used to reload the model in the onBeforeRender functions. This made
> > >> wicked open a transaction that continued until the save. But now I made
> > >> things different (more efficient). The problem now is how to get a
> > >> transaction run during the model update and save.
> > >>
> > >>
> > >>
> > >> >>IIRC you have a ListView involved. What's the type of
> > >> >>this.getDefaultModel() ?
> > >>
> > >> I checked this to make sure is the correct model. What I do is to set a
> > >> wrapper around. The component I use extends from panel and inside there
> > >> is a form and some other components that must use the model of the
> > >> panel. So I wrap it around with CompoundPropertyModel.
> > >>
> > >> ---------------
> > >>       public ScaffoldingForm(String id, IModel<T> scaffoldableModel) {
> > >>               //super(id, scaffoldableModel);
> > >>               super(id, new CompoundPropertyModel(scaffoldableModel));
> > >> ---------------
> > >>
> > >> The returning model is the CompoundPropertyModel. So seems to be ok.
> > >>
> > >>
> > >> Thank you in advance Sven.
> > >> I will try to make everything run in a unique transaction. I found this:
> > >> http://apache-wicket.1842946.n4.nabble.com/OpenSessionInView-OSIV-LoadableDetachableModel-and-Transactions-td1858513.html
> > >>
> > >> Maybe someone else have any other useful link.
> > >>
> > >> Thank you again.
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > >> For additional commands, e-mail: users-help@wicket.apache.org
> > >>
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setReuseItems(true) + transactions = ERROR (Solved!)

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
Oh man... It's almost solved but a lot of things happened in the middle:

        1.- I was using wicket examples configurations that makes no use
        of the org.apache.wicket.spring.SpringWebApplicationFactory in
        the WicketFilter. I normally use it but for this project wanted
        to stick to wicket example pages format. Solved problem 1 ->
        change filter definition.
        
        2.- wicket exampled had lots of libraries inside WEB-INF/lib. I
        didn't realized of this and everything got mixed. Different
        libraries, different versions all different. Solved problem 2 ->
        remove libraries and add dependencies to maven.
        
        3.- Filters!!! The order of the filters does matter. :D the OSIV
        MUST be mapped before the wicket filter. I thought that I knew
        this but did it wrooong. Solved problem 3 -> put OSIV before any
        other filter.
        
        
With this everything backs to work. The only problem that I have to
check now are transactions, and the order of doing things. Now object
got loaded after model updates and it lost changes before saving. But
the actual saving works. 


Thank you all guys!!! 

Hope this e-mail serves as reference to others... :D








El sáb, 04-06-2011 a las 07:27 -0400, James Carman escribió:
> Can you try to replicate what you're doing in a more simple fashion?
> Take your wicket framework code out of the mix.  Just try a
> wicket/spring/hibernate example.  You can use the Wicketopia example
> as a template if you want.
> 
> On Sat, Jun 4, 2011 at 6:01 AM, Gonzalo Aguilar Delgado
> <ga...@aguilardelgado.com> wrote:
> > I removed transactional pointcuts to see if this removes the issue.
> >
> > But the problem got worse. It seems that something is really wrong
> > configured in my project.
> >
> > DEBUG - DefaultListableBeanFactory - Returning cached instance of
> > singleton bean 'leadDAOBean'
> > DEBUG - SessionFactoryUtils        - Opening Hibernate Session
> > DEBUG - SessionImpl                - opened session at timestamp:
> > 13071814596
> > DEBUG - SessionFactoryUtils        - Closing Hibernate Session
> > ERROR - RequestCycle               - Can't instantiate page using
> > constructor public
> > org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()
> > org.apache.wicket.WicketRuntimeException: Can't instantiate page using
> > constructor public
> > org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()
> >
> > Watch this:
> >  SessionFactoryUtils        - Opening Hibernate Session
> >
> > It seems that is not the OSIV filter. It's hibernate who opens the
> > session. Why?
> >
> > It's strange because OSIV is configured:
> > DEBUG - OpenSessionInViewFilter    - Initializing filter
> > 'openSessionInViewFilter'
> > DEBUG - OpenSessionInViewFilter    - Filter 'openSessionInViewFilter'
> > configured successfully
> >
> > And the problem got worse without transactions:
> >
> > WicketMessage: Can't instantiate page using constructor public
> > org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()
> >
> > Root cause:
> >
> > org.hibernate.HibernateException: No Hibernate Session bound to thread,
> > and configuration does not allow creation of non-transactional one here
> >
> > Not even the first page is instantiated...
> >
> > Will search more...
> >
> >
> >
> >
> >
> > El sáb, 04-06-2011 a las 11:28 +0200, Gonzalo Aguilar Delgado escribió:
> >> >Hi,
> >> >are you sure your model is a LDM?
> >>
> >> Yes. Sure. Encapsulated by an CompoundPropertyModel.
> >> -------
> >> new CompoundPropertyModel(scaffoldableModel)
> >> -------
> >> /*
> >>                * Need this because wicket serializes everything and need to reload
> >> it when
> >>                * it's needed. This way wicket and hibernate plays well
> >>                */
> >>               IModel<Lead> scaffoldableModel = new
> >> LoadableHibernateModelImpl<Lead>(getFirst())
> >>               {
> >>                       /**
> >>                        *
> >>                        */
> >>                       private static final long serialVersionUID = 1L;
> >>                       @SpringBean(name = "leadDAOBean")
> >>                       private LeadDAO leadDAO;
> >>                       private UuidUserType uuid;
> >>
> >>                       @Override
> >>                       protected Lead load() {
> >>                               Lead lead = null;
> >>                               if(uuid!=null)
> >>                               {
> >>                                       lead = leadDAO.find(uuid);
> >>
> >>                               }
> >>                               return lead;
> >>                       }
> >>
> >>                       @Override
> >>                       protected void setNonTransientObject() {
> >>                               Lead lead =  this.getObject();
> >>                               if(lead!=null)
> >>                                       uuid = lead.getUuid();
> >>                       }
> >>
> >>
> >>               };
> >>
> >> --------
> >> And...
> >> ---------
> >> public abstract class LoadableHibernateModelImpl<T> extends
> >> LoadableDetachableModel<T>
> >>       implements LoadableHibernateModel<T>, IModel<T>
> >> ---------
> >>
> >> detach and load got called. So it's working. The problem seems to be
> >> transactions.
> >>
> >> I used to reload the model in the onBeforeRender functions. This made
> >> wicked open a transaction that continued until the save. But now I made
> >> things different (more efficient). The problem now is how to get a
> >> transaction run during the model update and save.
> >>
> >>
> >>
> >> >>IIRC you have a ListView involved. What's the type of
> >> >>this.getDefaultModel() ?
> >>
> >> I checked this to make sure is the correct model. What I do is to set a
> >> wrapper around. The component I use extends from panel and inside there
> >> is a form and some other components that must use the model of the
> >> panel. So I wrap it around with CompoundPropertyModel.
> >>
> >> ---------------
> >>       public ScaffoldingForm(String id, IModel<T> scaffoldableModel) {
> >>               //super(id, scaffoldableModel);
> >>               super(id, new CompoundPropertyModel(scaffoldableModel));
> >> ---------------
> >>
> >> The returning model is the CompoundPropertyModel. So seems to be ok.
> >>
> >>
> >> Thank you in advance Sven.
> >> I will try to make everything run in a unique transaction. I found this:
> >> http://apache-wicket.1842946.n4.nabble.com/OpenSessionInView-OSIV-LoadableDetachableModel-and-Transactions-td1858513.html
> >>
> >> Maybe someone else have any other useful link.
> >>
> >> Thank you again.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setReuseItems(true) + transactions = ERROR

Posted by James Carman <ja...@carmanconsulting.com>.
Can you try to replicate what you're doing in a more simple fashion?
Take your wicket framework code out of the mix.  Just try a
wicket/spring/hibernate example.  You can use the Wicketopia example
as a template if you want.

On Sat, Jun 4, 2011 at 6:01 AM, Gonzalo Aguilar Delgado
<ga...@aguilardelgado.com> wrote:
> I removed transactional pointcuts to see if this removes the issue.
>
> But the problem got worse. It seems that something is really wrong
> configured in my project.
>
> DEBUG - DefaultListableBeanFactory - Returning cached instance of
> singleton bean 'leadDAOBean'
> DEBUG - SessionFactoryUtils        - Opening Hibernate Session
> DEBUG - SessionImpl                - opened session at timestamp:
> 13071814596
> DEBUG - SessionFactoryUtils        - Closing Hibernate Session
> ERROR - RequestCycle               - Can't instantiate page using
> constructor public
> org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()
> org.apache.wicket.WicketRuntimeException: Can't instantiate page using
> constructor public
> org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()
>
> Watch this:
>  SessionFactoryUtils        - Opening Hibernate Session
>
> It seems that is not the OSIV filter. It's hibernate who opens the
> session. Why?
>
> It's strange because OSIV is configured:
> DEBUG - OpenSessionInViewFilter    - Initializing filter
> 'openSessionInViewFilter'
> DEBUG - OpenSessionInViewFilter    - Filter 'openSessionInViewFilter'
> configured successfully
>
> And the problem got worse without transactions:
>
> WicketMessage: Can't instantiate page using constructor public
> org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()
>
> Root cause:
>
> org.hibernate.HibernateException: No Hibernate Session bound to thread,
> and configuration does not allow creation of non-transactional one here
>
> Not even the first page is instantiated...
>
> Will search more...
>
>
>
>
>
> El sáb, 04-06-2011 a las 11:28 +0200, Gonzalo Aguilar Delgado escribió:
>> >Hi,
>> >are you sure your model is a LDM?
>>
>> Yes. Sure. Encapsulated by an CompoundPropertyModel.
>> -------
>> new CompoundPropertyModel(scaffoldableModel)
>> -------
>> /*
>>                * Need this because wicket serializes everything and need to reload
>> it when
>>                * it's needed. This way wicket and hibernate plays well
>>                */
>>               IModel<Lead> scaffoldableModel = new
>> LoadableHibernateModelImpl<Lead>(getFirst())
>>               {
>>                       /**
>>                        *
>>                        */
>>                       private static final long serialVersionUID = 1L;
>>                       @SpringBean(name = "leadDAOBean")
>>                       private LeadDAO leadDAO;
>>                       private UuidUserType uuid;
>>
>>                       @Override
>>                       protected Lead load() {
>>                               Lead lead = null;
>>                               if(uuid!=null)
>>                               {
>>                                       lead = leadDAO.find(uuid);
>>
>>                               }
>>                               return lead;
>>                       }
>>
>>                       @Override
>>                       protected void setNonTransientObject() {
>>                               Lead lead =  this.getObject();
>>                               if(lead!=null)
>>                                       uuid = lead.getUuid();
>>                       }
>>
>>
>>               };
>>
>> --------
>> And...
>> ---------
>> public abstract class LoadableHibernateModelImpl<T> extends
>> LoadableDetachableModel<T>
>>       implements LoadableHibernateModel<T>, IModel<T>
>> ---------
>>
>> detach and load got called. So it's working. The problem seems to be
>> transactions.
>>
>> I used to reload the model in the onBeforeRender functions. This made
>> wicked open a transaction that continued until the save. But now I made
>> things different (more efficient). The problem now is how to get a
>> transaction run during the model update and save.
>>
>>
>>
>> >>IIRC you have a ListView involved. What's the type of
>> >>this.getDefaultModel() ?
>>
>> I checked this to make sure is the correct model. What I do is to set a
>> wrapper around. The component I use extends from panel and inside there
>> is a form and some other components that must use the model of the
>> panel. So I wrap it around with CompoundPropertyModel.
>>
>> ---------------
>>       public ScaffoldingForm(String id, IModel<T> scaffoldableModel) {
>>               //super(id, scaffoldableModel);
>>               super(id, new CompoundPropertyModel(scaffoldableModel));
>> ---------------
>>
>> The returning model is the CompoundPropertyModel. So seems to be ok.
>>
>>
>> Thank you in advance Sven.
>> I will try to make everything run in a unique transaction. I found this:
>> http://apache-wicket.1842946.n4.nabble.com/OpenSessionInView-OSIV-LoadableDetachableModel-and-Transactions-td1858513.html
>>
>> Maybe someone else have any other useful link.
>>
>> Thank you again.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setReuseItems(true) + transactions = ERROR

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
I removed transactional pointcuts to see if this removes the issue.

But the problem got worse. It seems that something is really wrong
configured in my project.

DEBUG - DefaultListableBeanFactory - Returning cached instance of
singleton bean 'leadDAOBean'
DEBUG - SessionFactoryUtils        - Opening Hibernate Session
DEBUG - SessionImpl                - opened session at timestamp:
13071814596
DEBUG - SessionFactoryUtils        - Closing Hibernate Session
ERROR - RequestCycle               - Can't instantiate page using
constructor public
org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()
org.apache.wicket.WicketRuntimeException: Can't instantiate page using
constructor public
org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()

Watch this:
 SessionFactoryUtils        - Opening Hibernate Session

It seems that is not the OSIV filter. It's hibernate who opens the
session. Why?

It's strange because OSIV is configured:
DEBUG - OpenSessionInViewFilter    - Initializing filter
'openSessionInViewFilter'
DEBUG - OpenSessionInViewFilter    - Filter 'openSessionInViewFilter'
configured successfully

And the problem got worse without transactions:

WicketMessage: Can't instantiate page using constructor public
org.apache.wicket.examples.wscaffold.basicform.BasicFormPage()

Root cause:

org.hibernate.HibernateException: No Hibernate Session bound to thread,
and configuration does not allow creation of non-transactional one here

Not even the first page is instantiated... 

Will search more... 





El sáb, 04-06-2011 a las 11:28 +0200, Gonzalo Aguilar Delgado escribió:
> >Hi,
> >are you sure your model is a LDM?
> 
> Yes. Sure. Encapsulated by an CompoundPropertyModel.
> -------
> new CompoundPropertyModel(scaffoldableModel)
> -------
> /*
> 		 * Need this because wicket serializes everything and need to reload
> it when
> 		 * it's needed. This way wicket and hibernate plays well
> 		 */
> 		IModel<Lead> scaffoldableModel = new
> LoadableHibernateModelImpl<Lead>(getFirst())
> 		{
> 			/**
> 			 * 
> 			 */
> 			private static final long serialVersionUID = 1L;
> 			@SpringBean(name = "leadDAOBean")
> 			private LeadDAO leadDAO;
> 			private UuidUserType uuid;
> 			
> 			@Override
> 			protected Lead load() {
> 				Lead lead = null;
> 				if(uuid!=null)
> 				{
> 					lead = leadDAO.find(uuid);
> 					
> 				}
> 				return lead;
> 			}
> 
> 			@Override
> 			protected void setNonTransientObject() {
> 				Lead lead =  this.getObject();
> 				if(lead!=null)
> 					uuid = lead.getUuid();
> 			}
> 
> 			
> 		};
> 
> --------
> And...
> ---------
> public abstract class LoadableHibernateModelImpl<T> extends
> LoadableDetachableModel<T> 
> 	implements LoadableHibernateModel<T>, IModel<T>
> ---------
> 
> detach and load got called. So it's working. The problem seems to be
> transactions.
> 
> I used to reload the model in the onBeforeRender functions. This made
> wicked open a transaction that continued until the save. But now I made
> things different (more efficient). The problem now is how to get a
> transaction run during the model update and save.
> 
> 
> 
> >>IIRC you have a ListView involved. What's the type of 
> >>this.getDefaultModel() ?
> 
> I checked this to make sure is the correct model. What I do is to set a
> wrapper around. The component I use extends from panel and inside there
> is a form and some other components that must use the model of the
> panel. So I wrap it around with CompoundPropertyModel.
> 
> ---------------
> 	public ScaffoldingForm(String id, IModel<T> scaffoldableModel) {
> 		//super(id, scaffoldableModel);
> 		super(id, new CompoundPropertyModel(scaffoldableModel));
> ---------------
> 
> The returning model is the CompoundPropertyModel. So seems to be ok.
> 
> 
> Thank you in advance Sven.
> I will try to make everything run in a unique transaction. I found this:
> http://apache-wicket.1842946.n4.nabble.com/OpenSessionInView-OSIV-LoadableDetachableModel-and-Transactions-td1858513.html
> 
> Maybe someone else have any other useful link.
> 
> Thank you again.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setReuseItems(true) + transactions = ERROR

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
>Hi,
>are you sure your model is a LDM?

Yes. Sure. Encapsulated by an CompoundPropertyModel.
-------
new CompoundPropertyModel(scaffoldableModel)
-------
/*
		 * Need this because wicket serializes everything and need to reload
it when
		 * it's needed. This way wicket and hibernate plays well
		 */
		IModel<Lead> scaffoldableModel = new
LoadableHibernateModelImpl<Lead>(getFirst())
		{
			/**
			 * 
			 */
			private static final long serialVersionUID = 1L;
			@SpringBean(name = "leadDAOBean")
			private LeadDAO leadDAO;
			private UuidUserType uuid;
			
			@Override
			protected Lead load() {
				Lead lead = null;
				if(uuid!=null)
				{
					lead = leadDAO.find(uuid);
					
				}
				return lead;
			}

			@Override
			protected void setNonTransientObject() {
				Lead lead =  this.getObject();
				if(lead!=null)
					uuid = lead.getUuid();
			}

			
		};

--------
And...
---------
public abstract class LoadableHibernateModelImpl<T> extends
LoadableDetachableModel<T> 
	implements LoadableHibernateModel<T>, IModel<T>
---------

detach and load got called. So it's working. The problem seems to be
transactions.

I used to reload the model in the onBeforeRender functions. This made
wicked open a transaction that continued until the save. But now I made
things different (more efficient). The problem now is how to get a
transaction run during the model update and save.



>>IIRC you have a ListView involved. What's the type of 
>>this.getDefaultModel() ?

I checked this to make sure is the correct model. What I do is to set a
wrapper around. The component I use extends from panel and inside there
is a form and some other components that must use the model of the
panel. So I wrap it around with CompoundPropertyModel.

---------------
	public ScaffoldingForm(String id, IModel<T> scaffoldableModel) {
		//super(id, scaffoldableModel);
		super(id, new CompoundPropertyModel(scaffoldableModel));
---------------

The returning model is the CompoundPropertyModel. So seems to be ok.


Thank you in advance Sven.
I will try to make everything run in a unique transaction. I found this:
http://apache-wicket.1842946.n4.nabble.com/OpenSessionInView-OSIV-LoadableDetachableModel-and-Transactions-td1858513.html

Maybe someone else have any other useful link.

Thank you again.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setReuseItems(true) + transactions = ERROR

Posted by Sven Meier <sv...@meiers.net>.
Hi,

are you sure your model is a LDM?
IIRC you have a ListView involved. What's the type of 
this.getDefaultModel() ?

>I suppose that normal execution is ...

Yes, this is the way it is supposed to work.

Sven

On 06/03/2011 07:55 PM, Gonzalo Aguilar Delgado wrote:
> Hi Again,
>
> I checked why I'm receiving this nasty error. It seems that fails in
> this piece of code of the submit form:
>
> 			@Override
> 			protected void onSubmit() {
> 				log.debug("Saving content");
> 				IModel model = this.getDefaultModel();
> 				Lead object = (Lead)model.getObject();
> 				if(leadDAO!=null&&  object!=null)
> 				{
> ------>Is not attached                if(leadDAO.isAttached(object))
> 					leadDAO.save(object);
> 				}
> 				super.onSubmit();
> 			}
>
> That's strange because behind there is a LoadableDetachableModel  that
> loads this object. If it's loaded in the submit it MUST be same
> transaction that loaded it. Maybe it opened another one?
>
> Anyway it must be attached because nothing happened in the middle. But
> is not.
>
> Why? Is this normal?
>
> I suppose that normal execution is:
>
> 	* Submit is performed.
> 	* load() method of the model is executed because transient object is
> lost on this new http session.
> 	* object loaded is sent to the CompoundPropertyModel that encloses it.
> 	* The object is updated by the CompoundPropertyModel model.
> 	* onSubmit() is executed
> 	* getObject() does not executes load() function of the
> LoadableDetachableModel because it already was loaded.
> 	
> Here comes the question... So then, Why it's not attached? Who oppened a
> new transaction? Why?
>
> LOGS
> -------------------------
> When onSubmit logs shows as follows:
> DEBUG - Collections                - Collection found:
> [com.level2.enterprise.hibernate.generated.Lead.leadIdentifiers#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7], was: [com.level2.enterprise.hibernate.generated.Lead.leadIdentifiers#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7] (uninitialized)
> DEBUG - Collections                - Collection found:
> [com.level2.enterprise.hibernate.generated.Lead.leadBasicDetails#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7], was: [com.level2.enterprise.hibernate.generated.Lead.leadBasicDetails#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7] (uninitialized)
> DEBUG - tractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0
> deletions to 1 objects
> DEBUG - tractFlushingEventListener - Flushed: 0 (re)creations, 0
> updates, 0 removals to 2 collections
> DEBUG - Printer                    - listing entities:
> DEBUG - Printer                    -
> com.level2.enterprise.hibernate.generated.Lead{dateLead=2009-04-03
> 00:00:00, leadBasicDetails=<uninitialized>, email=test@test.com,
> dateCreated=2009-11-05 00:00:00, leadIdentifiers=<uninitialized>,
> idLot=132,
> uuid=com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7, dateUpdated=2011-04-27 20:52:15}
> DEBUG - JDBCTransaction            - re-enabling autocommit
> DEBUG - JDBCTransaction            - committed JDBC Connection
> DEBUG - ConnectionManager          - transaction completed on session
> with on_close connection release mode; be sure to close the session to
> release JDBC resources!
> DEBUG - ibernateTransactionManager - Closing Hibernate Session
> [org.hibernate.impl.SessionImpl@5ce0f945] after transaction
> DEBUG - SessionFactoryUtils        - Closing Hibernate Session
> DEBUG - ConnectionManager          - releasing JDBC connection [ (open
> PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
> DEBUG - ConnectionManager          - transaction completed on session
> with on_close connection release mode; be sure to close the session to
> release JDBC resources!
> --------------------------------------------------
> There's one transaction completed. I suppose the one that loaded it.
>
> The isAttached created a new transaction:
> --------------------------------------------------
> DEBUG - ScaffoldingForm            - Saving content
> DEBUG - ibernateTransactionManager - Creating new transaction with name
> [com.googlecode.genericdao.dao.hibernate.GenericDAO.isAttached]:
> PROPAGATION_REQUIRED,ISOLATION_DEFAULT
> DEBUG - SessionImpl                - opened session at timestamp:
> 13071235926
> DEBUG - ibernateTransactionManager - Opened new Session
> [org.hibernate.impl.SessionImpl@145edcf5] for Hibernate transaction
> DEBUG - ibernateTransactionManager - Preparing JDBC Connection of
> Hibernate Session [org.hibernate.impl.SessionImpl@145edcf5]
> DEBUG - JDBCTransaction            - begin
> DEBUG - ConnectionManager          - opening JDBC connection
> DEBUG - JDBCTransaction            - current autocommit status: true
> DEBUG - JDBCTransaction            - disabling autocommit
> DEBUG - ibernateTransactionManager - Exposing Hibernate transaction as
> JDBC transaction [jdbc:postgresql://127.0.0.1:5432/op_development_es,
> UserName=user_development, PostgreSQL Native Driver]
> DEBUG - ibernateTransactionManager - Initiating transaction commit
> DEBUG - ibernateTransactionManager - Committing Hibernate transaction on
> Session [org.hibernate.impl.SessionImpl@145edcf5]
> DEBUG - JDBCTransaction            - commit
> DEBUG - JDBCTransaction            - re-enabling autocommit
> DEBUG - JDBCTransaction            - committed JDBC Connection
> DEBUG - ConnectionManager          - transaction completed on session
> with on_close connection release mode; be sure to close the session to
> release JDBC resources!
> DEBUG - ibernateTransactionManager - Closing Hibernate Session
> [org.hibernate.impl.SessionImpl@145edcf5] after transaction
> DEBUG - SessionFactoryUtils        - Closing Hibernate Session
> DEBUG - ConnectionManager          - releasing JDBC connection [ (open
> PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
> DEBUG - ConnectionManager          - transaction completed on session
> with on_close connection release mode; be sure to close the session to
> release JDBC resources!
> --------------------------------------------
>
> Why? Because on the new transaction it will not be attached so I cannot
> save it. I suppose it must continue with the same transaction that
> loaded it.
>
>
>
> Thank you in advance.
>
>
>
>
>
>
> "No subestimes el poder de la gente estúpida en grupos grandes"
>
> El vie, 03-06-2011 a las 09:26 +0200, Gonzalo Aguilar Delgado escribió:
>> Hi Sven,
>>
>> Thank you for the update. I will check why they are not detached... They
>> should.
>>
>> Tnx again.
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setReuseItems(true) + transactions = ERROR

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
Hi Again, 

I checked why I'm receiving this nasty error. It seems that fails in
this piece of code of the submit form:

			@Override
			protected void onSubmit() {
				log.debug("Saving content");
				IModel model = this.getDefaultModel();
				Lead object = (Lead)model.getObject();
				if(leadDAO!=null && object!=null)
				{
------>Is not attached                if(leadDAO.isAttached(object))
					leadDAO.save(object);
				}
				super.onSubmit();
			}

That's strange because behind there is a LoadableDetachableModel  that
loads this object. If it's loaded in the submit it MUST be same
transaction that loaded it. Maybe it opened another one?

Anyway it must be attached because nothing happened in the middle. But
is not. 

Why? Is this normal?

I suppose that normal execution is:

	* Submit is performed.
	* load() method of the model is executed because transient object is
lost on this new http session.
	* object loaded is sent to the CompoundPropertyModel that encloses it.
	* The object is updated by the CompoundPropertyModel model.
	* onSubmit() is executed
	* getObject() does not executes load() function of the
LoadableDetachableModel because it already was loaded.
	
Here comes the question... So then, Why it's not attached? Who oppened a
new transaction? Why?

LOGS
-------------------------
When onSubmit logs shows as follows:
DEBUG - Collections                - Collection found:
[com.level2.enterprise.hibernate.generated.Lead.leadIdentifiers#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7], was: [com.level2.enterprise.hibernate.generated.Lead.leadIdentifiers#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7] (uninitialized)
DEBUG - Collections                - Collection found:
[com.level2.enterprise.hibernate.generated.Lead.leadBasicDetails#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7], was: [com.level2.enterprise.hibernate.generated.Lead.leadBasicDetails#com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7] (uninitialized)
DEBUG - tractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0
deletions to 1 objects
DEBUG - tractFlushingEventListener - Flushed: 0 (re)creations, 0
updates, 0 removals to 2 collections
DEBUG - Printer                    - listing entities:
DEBUG - Printer                    -
com.level2.enterprise.hibernate.generated.Lead{dateLead=2009-04-03
00:00:00, leadBasicDetails=<uninitialized>, email=test@test.com,
dateCreated=2009-11-05 00:00:00, leadIdentifiers=<uninitialized>,
idLot=132,
uuid=com.level2.enterprise.crm.hibernate.datatypes.UuidUserType@642b6fc7, dateUpdated=2011-04-27 20:52:15}
DEBUG - JDBCTransaction            - re-enabling autocommit
DEBUG - JDBCTransaction            - committed JDBC Connection
DEBUG - ConnectionManager          - transaction completed on session
with on_close connection release mode; be sure to close the session to
release JDBC resources!
DEBUG - ibernateTransactionManager - Closing Hibernate Session
[org.hibernate.impl.SessionImpl@5ce0f945] after transaction
DEBUG - SessionFactoryUtils        - Closing Hibernate Session
DEBUG - ConnectionManager          - releasing JDBC connection [ (open
PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
DEBUG - ConnectionManager          - transaction completed on session
with on_close connection release mode; be sure to close the session to
release JDBC resources!
--------------------------------------------------
There's one transaction completed. I suppose the one that loaded it.

The isAttached created a new transaction:
--------------------------------------------------
DEBUG - ScaffoldingForm            - Saving content
DEBUG - ibernateTransactionManager - Creating new transaction with name
[com.googlecode.genericdao.dao.hibernate.GenericDAO.isAttached]:
PROPAGATION_REQUIRED,ISOLATION_DEFAULT
DEBUG - SessionImpl                - opened session at timestamp:
13071235926
DEBUG - ibernateTransactionManager - Opened new Session
[org.hibernate.impl.SessionImpl@145edcf5] for Hibernate transaction
DEBUG - ibernateTransactionManager - Preparing JDBC Connection of
Hibernate Session [org.hibernate.impl.SessionImpl@145edcf5]
DEBUG - JDBCTransaction            - begin
DEBUG - ConnectionManager          - opening JDBC connection
DEBUG - JDBCTransaction            - current autocommit status: true
DEBUG - JDBCTransaction            - disabling autocommit
DEBUG - ibernateTransactionManager - Exposing Hibernate transaction as
JDBC transaction [jdbc:postgresql://127.0.0.1:5432/op_development_es,
UserName=user_development, PostgreSQL Native Driver]
DEBUG - ibernateTransactionManager - Initiating transaction commit
DEBUG - ibernateTransactionManager - Committing Hibernate transaction on
Session [org.hibernate.impl.SessionImpl@145edcf5]
DEBUG - JDBCTransaction            - commit
DEBUG - JDBCTransaction            - re-enabling autocommit
DEBUG - JDBCTransaction            - committed JDBC Connection
DEBUG - ConnectionManager          - transaction completed on session
with on_close connection release mode; be sure to close the session to
release JDBC resources!
DEBUG - ibernateTransactionManager - Closing Hibernate Session
[org.hibernate.impl.SessionImpl@145edcf5] after transaction
DEBUG - SessionFactoryUtils        - Closing Hibernate Session
DEBUG - ConnectionManager          - releasing JDBC connection [ (open
PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
DEBUG - ConnectionManager          - transaction completed on session
with on_close connection release mode; be sure to close the session to
release JDBC resources!
--------------------------------------------

Why? Because on the new transaction it will not be attached so I cannot
save it. I suppose it must continue with the same transaction that
loaded it.



Thank you in advance.






"No subestimes el poder de la gente estúpida en grupos grandes" 

El vie, 03-06-2011 a las 09:26 +0200, Gonzalo Aguilar Delgado escribió:
> Hi Sven, 
> 
> Thank you for the update. I will check why they are not detached... They
> should.
> 
> Tnx again.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setReuseItems(true) + transactions = ERROR

Posted by Gonzalo Aguilar Delgado <ga...@aguilardelgado.com>.
Hi Sven, 

Thank you for the update. I will check why they are not detached... They
should.

Tnx again.

-- 


 

"No subestimes el poder de la gente estúpida en grupos grandes" 

El vie, 03-06-2011 a las 09:00 +0200, Sven Meier escribió:
> Hi,
> 
> with resuseItems=true the listview will reuse items *on render*, but 
> this doesn't change whether model objects are serialized into the 
> session or not.
> 
> It rather seems that you're not detaching your models properly. I'd make 
> a wild guess that you keep references to your persistent objects in your 
> row components.
> 
> Best regards
> Sven
> 
> 
> On 06/03/2011 04:56 AM, Gonzalo Aguilar Delgado wrote:
> > Hello,
> >
> > I used to refresh all the components in the listview for each http
> > transaction.
> >
> > But now I tried to use the:
> >
> > setReuseItems(true);
> >
> > When using a ListView. Documentation says that is a must (but I made it
> > to work without it).
> >
> > The problem is that now the objects are serialized and deserialized and
> > not loaded from database in each http transaction. Result is that I
> > always get the following error:
> >
> > Row was updated or deleted by another transaction (or unsaved-value
> > mapping was incorrect)
> >
> >
> > How can I avoid this error and use the setReuseItems(true)?
> >
> > Thank you in advance.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: setReuseItems(true) + transactions = ERROR

Posted by Sven Meier <sv...@meiers.net>.
Hi,

with resuseItems=true the listview will reuse items *on render*, but 
this doesn't change whether model objects are serialized into the 
session or not.

It rather seems that you're not detaching your models properly. I'd make 
a wild guess that you keep references to your persistent objects in your 
row components.

Best regards
Sven


On 06/03/2011 04:56 AM, Gonzalo Aguilar Delgado wrote:
> Hello,
>
> I used to refresh all the components in the listview for each http
> transaction.
>
> But now I tried to use the:
>
> setReuseItems(true);
>
> When using a ListView. Documentation says that is a must (but I made it
> to work without it).
>
> The problem is that now the objects are serialized and deserialized and
> not loaded from database in each http transaction. Result is that I
> always get the following error:
>
> Row was updated or deleted by another transaction (or unsaved-value
> mapping was incorrect)
>
>
> How can I avoid this error and use the setReuseItems(true)?
>
> Thank you in advance.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org