Expand my Community achievements bar.

Push data changes from server to client

Avatar

Level 1

Hi,

I have a query regarding the usage of DataServiceTransaction API which is used to push database changes from server to client by notifying the LCDS that a change has been done to the database. I came across several chunks of code regarding this and tried to implement the same but was not successful in doing so.

It would be great if a complete code could be shared to achieve the same, i.e., notify the LCDS about the changes in the database.

Any quick help would be really appreciated as I am stuck and cannot really move in any direction.

Regards,

Shally

3 Replies

Avatar

Former Community Member

If you had created a new item and wanted to notify LCDS of the same, you need to do something similar to the below:

DataServiceTransaction dst = DataServiceTransaction.begin(/* True or False depending on whether you want to use JTA */);

dst.createItem(/* Name Of The Destination */, /* The created item instance */);

dst.commit();

This call should be made after object has already been persisted.

Avatar

Level 1

I can have a number of changes happening to the database which I am not even aware of. So there might be more than one change and if there are more changes, I do not know what exactly the changes are. So, it is not possible to do a createItem for each change.

A full example would really help.

Thanks for yoyr reply.

Regards,

Shally

Avatar

Level 1

Hi Ashish,

What do you mean by "This call should be made after object has already been persisted"?  How do you make sure the object has been persisted?

Thanks,

Collin