Hi everyone.
I have been using Hibernate locally with no issue. Now I need to use that in a (fat) client/server paradigm as described briefly below:
I have a fat client that has certain logic in it. Persistence happens on the server (backed by a DB). Communication between the two is through web services. Let say I have a class called Person and it has a reference to an object of another class Address. Lets say that each class has a (Long) id attribute as its unique identifier (which is mapped to the PK in the DB)
In the local version (no server, i.e. all happening by client and DB is local, too), I was using cascading to enforce the persistence of Address (and many other referenced objects) when I was saving Person. In the client/server situation, I create Person and Address objects on the client side and issue a local "save" which in effect sends them over to the server to be persisted there but the issue that I see is the following: the (client) save method call invokes the server's "save" method and all is good on the server (i.e. Person's persistence enforces the persistence of Address through cascading style) but the id's created on the server are not passed back to client, so on the client side, after "saving" Person, it won't have its id populated with the value from the server (i.e. DB) so if I make another change to Person (or Address) and save them again, it creates new entries in the DB. I can return the id back to the client when I do a save on the server for, say, Person objects and manually set the client's version of Person to have the same id but the issue is that manually finding all referenced objects (Address and the like) and setting their id's on the client side is not a reasonable solution.
What do people do in these cases?
Many thanks
Ali.
|