[jboss-user] [JBoss Seam] - Re: persist() / remove() at end of long running conversation

fjalvingh do-not-reply at jboss.com
Sun Jul 15 19:49:04 EDT 2007


I seem to have the same problem. I'm running seam 2.0.0b1 with hibernate 3.2.3, hbem 3.3.1 in JPA mode without EJB (Tomcat native).

I have a method as follows:


  | @Transactional(TransactionPropagationType.REQUIRED)
  | @Begin(flushMode=FlushModeType.MANUAL)
  | public String createNewTarget() {
  | 	System.out.println("method entered (fm=manual we hope)");
  | 	m_target = new Target();
  | 	m_target.setTargetSourceList(new ArrayList<TargetSourceModule>());
  | 
  | 	m_target.setKey("akey");
  | 	m_target.setName("Name");
  | 	System.out.println("method before persist()");
  | 	m_daoBuilder.save(m_target);
  | 	System.out.println("method after persist()");
  | 	return "newtarget";
  | }
  | 

and when this gets called Hibernate immediately inserts the record:

  | 01:26:41,964 DEBUG [SeamPhaseListener] before phase: INVOKE_APPLICATION 5
  | method entered (fm=manual we hope)
  | method before persist()
  | Hibernate: select nextval ('ab_target_sq')
  | *** fix: shouldDelayetc=false, fm=AUTO, ria=true
  | Hibernate: insert into ab_target (tgt_autoDiscover, tgt_key, tgt_name, tgt_repository_version, tgtid) values (?, ?, ?, ?, ?)
  | method after persist()
  | 01:27:03,786 DEBUG [Manager] Beginning long-running conversation
  | 

The ***fix line is displayed around the fix you proposed. As you can see flushmode is manual and requireimmediateresult is true.

I have debugged thru Seam and found one very odd thing though- the @Begin annotation seems to set the flushmode etc after the method is invoked, not before! It is done in ConversationInterceptor.aroundInvoke; the pertinent code is:

  | Object result = invocation.proceed();   
  | beginConversationIfNecessary(method, result);
  | endConversationIfNecessary(method, result);
  | return result;
  | 

The call to "beginConversation" sets the flush mode,  but after the deed has been done. I don't yet know if this is the cause of the problem but having the annotation "start" after the method call seems weird to me to say the least.


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

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



More information about the jboss-user mailing list