Upgrade
Sign In : Sign Up : Blog : Search: Language : Help :
Java Persistence Performance

dynamic weaving without persistence unit (jrebel)

by pranahata posted Apr 1 2015, 0:54

We have a client server app and we send the eclipselink entities from the server to the client using eclipselink copygroups. It is terribly great in the sense that we don't have to create DTOs as we can decide what parts of the object graph get serialized and we can keep all the business logic and validation in the domain model (entities).

One downside of it is that in order for this to work we need to statically weave the classes as the client side doesn't have a persistence unit and the weaving doesn't  seem to happen unless a pu containing the entities is initialized.

We are also using jrebel so at the moment every time we make a change to an entity we have to weave the entire jar statically which causes jrebel to reload every class in the jar.

Is it possible to programmatically (or statically) weave a single class? 

 

 


by jamesssss posted Apr 1 2015, 9:32
If your only sending objects one-way, you probably don't need to weave the client, the weaved fields will just disappear on the client. If you are sending objects both ways, then the weaving is required so the server know the difference between a field being null vs not instantiated.

If you include your persistence unit and eclipselink on the client (with meta-inf persistence.xml) then dynamic weaving should work on the client too. You may need a special or dummy persistence.xml that does not connect to the database.

Trying to weave one class at a time is probably a bad idea, as classes reference other classes, and you have to weave the class before it is loaded, otherwise it is too late.

Here is the JavaDoc for the static weaver,

http://www.eclipse.org/eclipselink/api/2.6/org/eclipse/persistence/tools/weaving/jpa/package-frame.html

and source code,

http://git.eclipse.org/c/eclipselink/eclipselink.runtime.git/tree/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/tools/weaving/jpa

Thumbs up: 0, thumbs down: 0, stars: 0.0
Views: 506, today: 0, week: 1, month: 11

Id: 330252
Posted: Apr 1 2015, 0:54
Replies: 1
Views: 475, today: 2, week: 6, month: 11
I'm sure
Flag graphic as offensive, or in violation of site rules