Database transaction

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Database transaction

acec acec
In my controller.xml, I defined the following
request-map, which event type is java.
<request-map uri="EditResourceHeaderList">
 <security auth="true" https="true"/>
 <event type="java"
path="org.ofbiz.product.resourcemapping.ResourceHeaderListServices"
invoke="editResourceHeaderList"/>
 <response name="success" type="none"/>
 <response name="error" type="none"/>
</request-map>

In my editResourceHeaderList function, I will remove
old record and create a new record. How can I make
sure two steps in one database transaction?

GenericValue oldResourceHeaderList =
delegator.findByPrimaryKey(entity, UtilMisc.toMap(
                    "headerId", oldHeaderId,
"resourceId", oldResourceId));
if (oldResourceHeaderList != null) {
                oldResourceHeaderList.remove();
            }
           
            GenericValue newResourceHeaderList =
delegator.makeValue(entity, UtilMisc.toMap(
                    "headerId", headerId,
"resourceId", resourceId));
            delegator.create(newResourceHeaderList);


Thanks a lot.
Tomcat Acec


      __________________________________________________________________
Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com
Reply | Threaded
Open this post in threaded view
|

Re: Database transaction

BJ Freeman
look at using delegator.store()


acec acec sent the following on 4/28/2008 2:22 PM:

> In my controller.xml, I defined the following
> request-map, which event type is java.
> <request-map uri="EditResourceHeaderList">
>  <security auth="true" https="true"/>
>  <event type="java"
> path="org.ofbiz.product.resourcemapping.ResourceHeaderListServices"
> invoke="editResourceHeaderList"/>
>  <response name="success" type="none"/>
>  <response name="error" type="none"/>
> </request-map>
>
> In my editResourceHeaderList function, I will remove
> old record and create a new record. How can I make
> sure two steps in one database transaction?
>
> GenericValue oldResourceHeaderList =
> delegator.findByPrimaryKey(entity, UtilMisc.toMap(
>                     "headerId", oldHeaderId,
> "resourceId", oldResourceId));
> if (oldResourceHeaderList != null) {
>                 oldResourceHeaderList.remove();
>             }
>            
>             GenericValue newResourceHeaderList =
> delegator.makeValue(entity, UtilMisc.toMap(
>                     "headerId", headerId,
> "resourceId", resourceId));
>             delegator.create(newResourceHeaderList);
>
>
> Thanks a lot.
> Tomcat Acec
>
>
>       __________________________________________________________________
> Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com
>
>
>