[jboss-user] [JBoss Seam] - Form submit trigger many updates

milesif do-not-reply at jboss.com
Wed Jan 3 18:55:00 EST 2007


Hi everybody,

I have a class based on the "Seam APplication Framework" defined as

  |          @Name("machineHome")
  |          class MachineHome extends EntityHome<Machine>
  | 
I submit a form whose fields are bound to variables of type

  |          #{machineHome.instance.fieldName} 
  | 
calling the action (I overrid the method just to play with exceptions)
        
  |         @Override
  | 	@Transactional
  | 	public String update()
  | 	{
  | 		try {
  | 			getEntityManager().joinTransaction();
  | 			getEntityManager().flush();
  | 			updatedMessage();
  | 			return "updated";
  | 		} catch (Exception e) {
  | 			e.printStackTrace();
  | 			return "";
  | 		}
  | 	}
  | 
When I submit the form I see the following log message

  | 00:32:57,454 INFO  [STDOUT] Hibernate: update public.machines set version=?, start_date=?, status=?, id_unit=?, machine_code=?, purchase_date=?, last_maintenance_date=?, dismission_date=?, expected_life=?, id_machine_type=?, maintenance_category=? where id_machine=?
  | 
I see it as many times as the number of fields I modified before submitting the form.
This happens if in faces-config.xml I set

  | <lifecycle>
  |     <phase-listener>
  |          org.jboss.seam.jsf.SeamPhaseListener
  |     </phase-listener>
  | </lifecycle>
  | 
while it does not happen if I set

  | <lifecycle>
  |      <phase-listener>
  |           org.jboss.seam.jsf.TransactionalSeamPhaseListener
  |      </phase-listener>
  | </lifecycle>
  | 
In both cases the entity manager get flushed (and the changes saved) even if I do not call flush() explicitely and when I call a method that is not tagged as @Transactional.
Can anybody help me to understand why that happens and how to flush the entity manager only when I call flush explicitely? Should I use a @Stateful session bean ?

Thanks to anybody for help.

Ciao Francesco









View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3997760#3997760

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3997760



More information about the jboss-user mailing list