Archive for September, 2008

LiveCycle Data Services 2.6 – new features (4)

Support for offline synchronization was improved in LiveCycle Data Services 2.6 – the Flex applications deployed on the AIR runtime will use a cache base on SQLite database instead of a Local Shared Objects cache.

There are several resources describing in details this feature in detail and providing some samples – Cristophe Coenraets blog, an article on Inside RIA and the developer guide.

Of course, you can synchronize your application without using LiveCycle Data Services and use whatever suits you best (SQLite or LSO), in fact I know several developers who have been doing this for the Flex applications they deploy on browser for a long time. There are, however, advantages to using the LiveCycle Data Services solution for the offline/online synchronization are:

  • you do not have to write additional code to deal with synchronization so you can save a lot of time
  • you can use the already implemented conflict resolution model

LiveCycle Data Services and Hibernate one-to-many association

I’ve noticed that several peoples have problems implementing one-to-many associations so I decided to write a simple example (using HibernateAnnotationsAssembler). It contains several use cases of working with this kind of association (more than the samples provided with LCDS distribution):

  • you can modify (update, add, delete) a parent or a child and see the synchronization between several clients. Note that when deleting the parent I have to programmatically delete the children’s – cascade on delete does not work yet automatically
  • you can create a parent and a child in the same transaction (no need to create the parent and save it before adding the children)
  • you can revert your modifications
  • conflict management should work both for parents and children
  • you can check the generated SQL in the server console (I’ve tested with MySQL database) and see the effect of the load-on-demand and page-size attributes).
  • you can check what happens when cache-items is set to true and when it is set to false

Note: I’ve mapped the one-to-many association as bidirectional (The parent has a list of children and a child has a reference to the parent). However if you have a large number of children associated with a parent, then from a performance point of view it is better to drop the list from the parent)

Also because the association is bidirectional I had to add the read-only attribute for the list of children (to notify the dataservice that it should look for updates only at the other end). If you will set the value to “false” you will see some strange SQL commands.

I’ve used Java 1.5 and Hibernate annotations so there is really not much code. You can download it from here (it’s an archive containing a Flex project and a readme.txt).