I'm currently building a P2P-system which uses Protocol Buffers for all communication between the peers. There's also a some centralized parts of the system where the peers communicate with a server. The server uses JPA to store the data it has about the peers.
So essentially the clients has its data in Protocol Buffers-messages and the server in JPA-entities. My question is therefore if there's a way to automatically convert between them?
What I'm looking for is:
- A generator of JPA-entities from .protos-files OR
- A generator of .protos-files from JPA-entities AND
- Some way to automatically convert between them at runtime so I don't have create the code to do it manually for every new class.
Ideally you could take it one step further and have them both be the same classes (i.e. Protocol Buffers with JPA annotations) but if that's not attainable the above would work as well.
Has this been done and if not do you think it's feasible to implement in a reasonable amount of time?