every one.
I am developing a generic table component for a Swing based client application. This table component is supposed to act as user interface at client side and call remote EJB interface to perform CRUD actions.
The data model of the table is basically a List of jpa entitities. I have no problem in implementing query functions, but when there comes persist actions I am a little confused about the 'commit' strategy .
I am think of following approaches:
Try to manage a edited/inserted/deleted row List in this table and send the List to remote EJB when user clicks "save" button. EJB will perform CUD actions in CMT. Managing the list seems challenging since user could do sequence-matters actions that causes CUD fails at server side. For example, at client side, a user can first insert a record with exactly same data of a already existed record and then delete the existed record. If the database table has unique constraints, save action will fail since INSERT will happen first. So I have to prevent cases like this before sending the List.
Make the table component autocommit style. Every insert\update\delete action that end user does will call a remote method so that the data is persisted. I think this approach will be slow if the client is deployed at places with large network lantency. Also My Table component has to provide extra features, such as fix at row until the input data is valid , in case the table component is operating a database schema with constrains like not null/unique.
Get UserTransaction and manage transaction at client side. I read something about this but I have not really figure out how to implement.
Which one is the right approach? Thank you for any advice.