Class JpaHelper
- java.lang.Object
-
- com.devonfw.module.jpa.dataaccess.api.JpaHelper
-
public class JpaHelper extends Object
Helper class for generic handling of persistenceentities(based onEntityManager). In some cases it is required to access JPA features in a static way. E.g. a common case is a setter in yourentityfor areferencefrom anETOthat 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
-
-
Constructor Summary
Constructors Constructor Description JpaHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E extends GenericEntity<?>,P extends E>
voidasEntities(Collection<? extends E> input, Class<P> entityClass, Collection<P> output)static <E> EasEntity(Ref<?,? super E> reference, Class<E> entityClass)static RevisionMetadataTypeasRevisionMetaData(AdvancedRevisionEntity revEntity)This is the newer implementation of RevisionMetadataType should be used withRevisionMetadata
-
-
-
Method Detail
-
asEntities
public static <E extends GenericEntity<?>,P extends E> void asEntities(Collection<? extends E> input, Class<P> entityClass, Collection<P> output)
- Type Parameters:
E- generic type of the inputentities(most commonly the entity interface).P- generic type of the outputentities.- Parameters:
input- theCollectionofentities(e.g.ETOs) to use as input.entityClass- theClassreflecting theentity.output- dieCollectionwhere toaddtheentitiescorresponding to the inputentities. Most probablyemptybut may also already contain entities so this method will add additional entities.
-
asRevisionMetaData
public static RevisionMetadataType asRevisionMetaData(AdvancedRevisionEntity revEntity)
This is the newer implementation of RevisionMetadataType should be used withRevisionMetadata- Parameters:
revEntity- dieAdvancedRevisionEntity.- Returns:
- die Instanz von
RevisionMetadataTypebzw.nullfallsrevisionden Wertnullhat.
-
-