public static final class

OfflineODataRequestOptions.TransactionID

extends Object
java.lang.Object
   ↳ com.sap.cloud.mobile.odata.offline.OfflineODataRequestOptions.TransactionID

Class Overview

The class represents a TransactionID instance.

To use TransactionID when transaction builder is enabled.

Here is an example of creating a Customer and a related Order and having both is true. operations use the new Customer's entity ID as the transaction ID so that they both get put in the same transaction by the transaction builder:

 EntityValue newCustomer = EntityValue.ofType( customerEntityType );
 EntityValue newOrder = EntityValue.ofType( orderEntityType );

 // Fill in newCustomer and newOrder properties here...

 // This will create the new customer and the transaction ID of the request
 // will be the generated entity ID.
 OfflineODataRequestOptions createCustomerOptions = new OfflineODataRequestOptions()
 createCustomerOptions.setTransactionID( TransactionID.UseGeneratedIDForTransactionID );
 service.createRelatedEntity( orderEntityType, customerEntityType, ordersNavigationProperty, HttpHeaders.empty, createCustomerOptions );
 
 

Summary

Fields
public static final OfflineODataRequestOptions.TransactionID UseGeneratedIDForTransactionID A constant to specify to use the generated entity ID for a created entity or media entity as the transaction ID for the request.
Public Constructors
TransactionID(String value)
Sets a pre-defined string as the transaction ID.
TransactionID(EntityValue value)
Sets the entity ID of the specified EntityValue as the transaction ID.
Public Methods
EntityValue getEntityValue()
Returns the entity value if transaction ID is EntityValue.
String getStringLiteral()
Returns the string value if transaction ID is StringLiteral.
OfflineODataRequestOptions.TransactionIDType getTransactionIDType()
Returns the TransactionIDType.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final OfflineODataRequestOptions.TransactionID UseGeneratedIDForTransactionID

A constant to specify to use the generated entity ID for a created entity or media entity as the transaction ID for the request. Using the generated entity ID as a transaction ID is ideal for cases where requests for a new entity need to be grouped into a transaction but there is no other pre-defined transaction ID. Using the generated entity ID as a transaction ID is also ideal for cases where a graph of related entities (for example, a parent-child hierarchy) needs to be grouped into a transaction and the entity ID of the to be created root is the ideal choice for the transaction ID. Note that this can be used in a change set and subsequent requests in the change set can reference the created entity (by EntityValue) to also be grouped in the same transaction.

Public Constructors

public TransactionID (String value)

Sets a pre-defined string as the transaction ID.

Parameters
value the string value, the value can not be empty or contains only white spaces.

public TransactionID (EntityValue value)

Sets the entity ID of the specified EntityValue as the transaction ID. This is a convenient way to have a graph of entities (for example, a parent-child hierarchy) all be grouped into the same transaction by referencing the root entity as the transaction ID.

Parameters
value the entity value.

Public Methods

public EntityValue getEntityValue ()

Returns the entity value if transaction ID is EntityValue.

Returns
  • the entity value if transaction ID is EntityValue.

public String getStringLiteral ()

Returns the string value if transaction ID is StringLiteral.

Returns
  • the string value if transaction ID is StringLiteral.

public OfflineODataRequestOptions.TransactionIDType getTransactionIDType ()

Returns the TransactionIDType.

Returns
  • the TransactionIDType is used.