Julius Schorzman
Julius Schorzman

Reputation: 1432

Accessing Play Framework Model Outside of Play Framework

We have a large offline process that updates the model I designed inside of Play Framework. I think it makes sense to keep this code as a stand-alone project -- but I would like it to be able to use the JPA Model designed inside Play.

I'm wondering if there's a good way to handle this -- a way to reference the JPA Model independently of Play Framework (inside another vanilla Java project).

Another option is to create an API that the external process calls, which is what I've done so far, but it introduces a lot of unnecessary network latency.

Any pointers on how to accomplish this?

Upvotes: 3

Views: 501

Answers (1)

Damo
Damo

Reputation: 11540

Passing around a Play specific JPA entity (ie. that extends Model) is probably not a good idea. You'd be introducing a dependency on the Play jars where they are not required.

As I see it you have two viable options:

  1. Create the object as a POJO and use a Hibernate Xml Config (for Play versions less than 2.0) to define the mapping to the database. You can keep the pojo and the config entirely separate - ie. keep the config in the classpath of your Play App.

  2. Pass your object around in a serialized form eg. XML or JSON.

Upvotes: 2

Related Questions