Class JpaHelper


  • public class JpaHelper
    extends Object
    Helper class for generic handling of persistence entities (based on EntityManager). In some cases it is required to access JPA features in a static way. E.g. a common case is a setter in your entity for a reference from an ETO that can be achieved via the following code:
     @Entity
     @Table("Foo")
     public class FooEntity extends ApplicationPersistenceEntity implements Foo {
       @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
       @JoinColumn(name = "bar")
       private BarEntity bar;
       ...
       @Override
       public void setBarId(IdRef<Bar> barId) {
         this.bar = JpaHelper.asEntity(barId, BarEntity.class);
       }
     }
     
    Since:
    3.0.0