Reputation: 451
When using Persistence frameworks like Hibernate, JPA etc. on the server side, what are the general practices of passing on the data between client and server ? Are there any existing design patterns for the same ?
Thanks.
Upvotes: 3
Views: 1137
Reputation: 92140
I do not know about patterns but I know in a design using for example EJB3 with JPA that it's not recommended to pass JPA entities to client through remote EJB's because proxies stay and it can generate a lot of useless network traffic. You'd better detach your entities or give to client simple value objects.
Upvotes: 1
Reputation: 7802
As Sebastien Lorber said you may use DTO pattern, i.e. to copy entities to POJOs. But you may send JPA entities to client to avoid DTO's. There are two problems with sending entities:
Upvotes: 0
Reputation: 1499
Client-server, or with the inclusion of database, 3-tier architecture is a design pattern itself. The question is rather which technology should be used in the communication. There are many choices, e.g. HTTP, TCP, UDP, JMS, XMLRPC, RMI, CORBA, C RPC or flash-drives carried by post pigeons. In general, it is advised to
Regarding your question on dependency on the chosen persistence framework, I think there is none. Your choice of using e.g. Hibernate does not enforce or exclude any client-server communication technologies.
Upvotes: 1
Reputation: 6795
Ideally, the persistence layer should be quite separate from your client-server comms layer. While not strictly a pattern, the idea here is loose coupling.
As HerQuLe said, you should try to make sure that the data you send between client and server is just POJO style info, rather than serializing a (possibly much more complex) proxy.
Upvotes: 0