can someone help me plz?
i am trying to get a synchronization between N "clients" database to 1 Big "Server" database (kind of repository/backup database). Its ok, i got a way to make their sync fine.
but, it was demanded the "Server" will be a "Client" application too, with same Java classes, models, entities, business, etc..
I am trying to find a solution to this Server database holds all database content from all Clients without making major changes to my entities (cause i will need to apply then on Client too)
This is an example of what i tried, but no success how to implement it on JPA and Serialization through EJB remotes.
@Entity
@Table(name="crud_sync")
public class CrudSync implements Serialization{
private static final long serialVersionUID = 1L;
@Id private Long id;
private String data;
//...ommited...
}
supposing i have this CrudSync entity.
On the N clients side database, i would have a table with columns:
ID - Number - PK
Data - Varchar
etc...
on the 1 Server side, i would like to have a table with:
ID - Number - PK
ClientPK - Number // the ID on Client database table
ClientId - Number // the Client code (1,2,3,4.. etc..)
// UQ (ClientPK,ClientID)
Data - Varchar
etc...
or even a composite PK
ClientPK - Number - PK // the ID on Client database table
ClientId - Number - PK // the Client code (1,2,3,4.. etc..)
Data - Varchar
etc...
but i am not sure how to achieve that using the same Entities on both sides, if its even possible..
another solution could maybe create separated JAR/EAR for Client and Server. doing that, what should i change in Entities/JPA annotations? what class should be separated to Client/Server JAR/EAR ?
Any other suggestion on how to make a (N Client <-> 1 Server) database?
Its mandatory to Clients work offline, so they need to have their own Database running, also its mandatory to have the same application on Server, because it will be possible to create entities on Server and those will be sent to Client (vice-versa).
I am using JBoss AS 7.1, JPA 2, EJB 3.1.
Thanks in advance. Anon.