-
1. Re: What does the sync-on-commit-only do.
michal.wroblewski Oct 29, 2010 1:38 AM (in response to jbosspercy)The main description what i found it is located in jboss_5_0.dtd.
<!-- The sync-on-commit-only element determines the behavior of ejbStore
calls on finds, selects and removes. If set to true, ejbStore will only be
called on transaction commit.
-->
<!ELEMENT sync-on-commit-only (#PCDATA)>1. On ejb invoke set method;
2. Result is view for ejb not on DB.
3. I must to invoke some find, select see description above.
If you have invoke finder on current data, include change in the current transaction, you must configurate to false.
False determine invoke store before calls on finds, selects and removes.
If you hase on true, DB not view change on ejb.
-
2. What does the sync-on-commit-only do.
michal.wroblewski Feb 1, 2011 12:55 AM (in response to michal.wroblewski)Because I had problem with invoke insert after update on the same table, constrain on DB see old vlaue of fields,
I had add
<container-configuration extends="Instance Per Transaction CMP 2.x EntityBean">
<container-name>XYZ</container-name>
<!--call-logging>false</call-logging-->
<sync-on-commit-only>false</sync-on-commit-only>
<insert-after-ejb-post-create>true</insert-after-ejb-post-create>
<container-interceptors>
<interceptor>.......EntitySynchronizationOnSetInterceptor</interceptor>.
public class EntitySynchronizationOnSetInterceptor extends AbstractInterceptor{
protected EntityContainer container;
public Container getContainer(){
return container;
}
public void setContainer(Container container){
this.container = (EntityContainer)container;
}
public Object invoke(Invocation invocation) throws Exception {
if(invocation.getMethod()!= null
&& invocation.getMethod().getName().startsWith("set")){
EntityEnterpriseContext ctx = (EntityEnterpriseContext)invocation.getEnterpriseContext();
Object result = super.invoke(invocation);
container.invokeEjbStore(ctx);
container.storeEntity(ctx);
return result;
}else{
return super.invoke(invocation);
}
}
}
Then connect concret EJB with container-name.
It resolved my problem.
Regards