actframework / act-eclipselink

Provide JPA support via EclipseLink
Apache License 2.0
1 stars 1 forks source link

Act-Eclipselink could not support weaving #8

Open leeaee opened 6 years ago

leeaee commented 6 years ago
  1. Define classes with @OneToMany and @ManyToOne
    public class UserCart  {
    ...
    @NotNull
    @OneToMany(mappedBy = "userCart", fetch = FetchType.LAZY)
    public List<Product> products;
    }
    public class Product implements SimpleBean {
    ...
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_cart_id")
    public UserCart userCart;
    }
  2. Add configuration: db.default.eclipselink.weaving=true/static
  3. Add -javaagent:eclipselink.jar to JVM command line to enable Dynamic Weaving

When ACT startup, it still displays the warning

 Reverting the lazy setting on the OneToOne or ManyToOne attribute [userCart] for the entity class [class Product] since weaving was not enabled or did not occur.

Could ACT support eclipselink weaving now?

greenlaw110 commented 6 years ago

Seems like this is because act-eclipselink does not have the right dependencies setup.

If we take a look at project https://github.com/rtatol/dropwizard-guice-jpa-eclipselink, we found it has dependency of org.eclipse.persistence.jpa, while act-eclipse has dependency of eclipselink.

After we changed dependency of act-eclipselink, the app is now able to do lazy load. See https://github.com/greenlaw110/act-eclipselink-lazyload-demo