|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.soyatec.windowsazure.table.TableServiceContext
public class TableServiceContext
This class provide API to manipulate ITableServiceEntity, such as insert, update, delete etc.
TableServiceContext implements the IBatchExecutor. Some TRANSCATION
supported operations can be enlist a single batch operation. Example:
SampleEntity sampleEntity1 = createSampleEntity();
SampleEntity sampleEntity2 = createSampleEntity();
try {
tableServiceContext.startBatch();
tableServiceContext.insertEntity(sampleEntity1);
tableServiceContext.insertEntity(sampleEntity2);
tableServiceContext.executeBatch();
catch(Exception e){
//
}
For more detail about Batch operation, see
IBatchExecutor.
| Field Summary |
|---|
| Fields inherited from interface org.soyatec.windowsazure.table.IBatchExecutor |
|---|
BATCH_BOUNDARY_PREFIX, BATCH_PATH, CHANGESET_BOUNDARY_PREFIX |
| Constructor Summary | |
|---|---|
TableServiceContext(ITable table)
|
|
| Method Summary | ||
|---|---|---|
void |
clearBatch()
Cleanup current batch |
|
void |
deleteEntity(ITableServiceEntity obj)
Deletes an entity within a table |
|
void |
deleteEntityIfNotModified(ITableServiceEntity obj)
Deletes a table entity if the entity is not modified after it is loaded from azure table storage. |
|
void |
executeBatch()
Commit current batch. |
|
java.lang.Class<? extends ITableServiceEntity> |
getModelClass()
Default, azure table entities are retrieved as the instances of class SimpleTableServiceEntity. |
|
void |
insertEntity(ITableServiceEntity obj)
Inserts a new entity into a table. |
|
boolean |
isInBatch()
This operation indicates whether there is batch. |
|
|
loadEntity(T entity)
Load the entity within table by the entity identifier(PartitionKey and RowKey). |
|
void |
mergeEntity(ITableServiceEntity obj)
Merges table entity |
|
java.util.List<ITableServiceEntity> |
retrieveEntities(java.lang.Class<? extends ITableServiceEntity> modelClass)
This operation queries entities in a table and set the model class of the table. |
|
java.util.List<ITableServiceEntity> |
retrieveEntities(org.soyatec.windowsazure.table.internal.CloudTableQuery query,
java.lang.Class<? extends ITableServiceEntity> modelClass)
This operation queries entities in a table and set the model class of the table.. |
|
java.util.List<ITableServiceEntity> |
retrieveEntities(java.lang.String queryExpression,
java.lang.Class<? extends ITableServiceEntity> modelClass)
This operation queries entities in a table and set the model class of the table.. |
|
java.util.List<ITableServiceEntity> |
retrieveEntitiesByKey(java.lang.String partitionKey,
java.lang.String rowKey,
java.lang.Class<? extends ITableServiceEntity> modelClass)
|
|
void |
setModelClass(java.lang.Class<? extends ITableServiceEntity> modelClass)
Set model class for this table. |
|
void |
startBatch()
Starts a new batch operation set. |
|
void |
updateEntity(ITableServiceEntity obj)
Updates an existing entity within a table by replacing it. |
|
void |
updateEntityIfNotModified(ITableServiceEntity obj)
Updates table entity if the entity is not modified after it is loaded from azure table storage. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TableServiceContext(ITable table)
| Method Detail |
|---|
public void deleteEntity(ITableServiceEntity obj)
throws StorageException
obj - the object to be deleted
StorageException - If entity is not exists, an exception is also thrown.
public void deleteEntityIfNotModified(ITableServiceEntity obj)
throws StorageException
obj - the object to be deleted
StorageException#deleteEntity(AbstractTableServiceEntity)}
public <T extends ITableServiceEntity> T loadEntity(T entity)
throws StorageException
T - AbstractTableServiceEntity instance of subclass of
AbstractTableServiceEntity instanceentity - Specified Entity
StorageException
public java.util.List<ITableServiceEntity> retrieveEntities(java.lang.String queryExpression,
java.lang.Class<? extends ITableServiceEntity> modelClass)
throws StorageException
queryExpression - If queryExpression is not given, all rows are return.modelClass - If modelClass is not null, set the given class to the table's model class.
StorageException
public java.util.List<ITableServiceEntity> retrieveEntities(org.soyatec.windowsazure.table.internal.CloudTableQuery query,
java.lang.Class<? extends ITableServiceEntity> modelClass)
throws StorageException
query - A cloudTableQuerymodelClass - If modelClass is not null, set the given class to the table's model class.
StorageException
public java.util.List<ITableServiceEntity> retrieveEntities(java.lang.Class<? extends ITableServiceEntity> modelClass)
throws StorageException
modelClass - If modelClass is not null, set the given class to the table's model class.
StorageException
public java.util.List<ITableServiceEntity> retrieveEntitiesByKey(java.lang.String partitionKey,
java.lang.String rowKey,
java.lang.Class<? extends ITableServiceEntity> modelClass)
throws StorageException
partitionKey - rowKey - modelClass - If modelClass is not null, set the given class to the table's model class.
StorageException
public void insertEntity(ITableServiceEntity obj)
throws StorageException
obj - The object to be inserted. The entity shoule be instance of
AbstractTableServiceEntity or subclass of
AbstractTableServiceEntity
StorageException
public void updateEntity(ITableServiceEntity obj)
throws StorageException
obj - the object to be updated
StorageException
public void updateEntityIfNotModified(ITableServiceEntity obj)
throws StorageException
obj - the object to be updated
StorageException#updateEntity(AbstractTableServiceEntity)}public java.lang.Class<? extends ITableServiceEntity> getModelClass()
SimpleTableServiceEntity. A list of
SimpleTableServiceEntity is return when retrieve entities from
table service.
Model class can be changed to specified table service to
represent more Model details.
Model class must be subclass of
AbstractTableServiceEntity.
Get the model class for this table.
#modelClasspublic void setModelClass(java.lang.Class<? extends ITableServiceEntity> modelClass)
modelClass - #modelClass}
public void mergeEntity(ITableServiceEntity obj)
throws StorageException
obj - the object to be merged
StorageExceptionpublic void startBatch()
startBatch in interface IBatchExecutorpublic void clearBatch()
clearBatch in interface IBatchExecutorpublic void executeBatch()
executeBatch in interface IBatchExecutorpublic boolean isInBatch()
isInBatch in interface IBatchExecutor
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||