![JAR search and dependency download from the Maven repository](/logo.png)
io.datafx.crud.jpa.JpaCrudService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of crud Show documentation
Show all versions of crud Show documentation
Visualizing Enterprise Data in JavaFX
package io.datafx.crud.jpa;
import io.datafx.crud.BasicCrudService;
import io.datafx.crud.util.EntityWithId;
import javax.persistence.EntityManager;
import java.io.Serializable;
import java.util.function.Supplier;
public class JpaCrudService, T extends Serializable> extends BasicCrudService {
private CreateOnceSupplier entityManagerSupplier;
private EntityManager createdManager;
public JpaCrudService(EntityManager entityManager, Class entityClass) {
this(() -> entityManager, entityClass);
}
public JpaCrudService(Supplier entityManagerSupplier, Class entityClass) {
this(new CreateOnceSupplier(entityManagerSupplier), entityClass);
}
public JpaCrudService(CreateOnceSupplier entityManagerSupplier, Class entityClass) {
super(new JpaGetAllCall(entityManagerSupplier, entityClass),
new JpaGetByIdCall(entityManagerSupplier, entityClass),
new JpaDeleteCall(entityManagerSupplier, entityClass),
new JpaPersistCall(entityManagerSupplier),
new JpaUpdateCall(entityManagerSupplier));
this.entityManagerSupplier = entityManagerSupplier;
}
public EntityManager getEntityManager() {
if(createdManager == null) {
createdManager = entityManagerSupplier.get();
}
return createdManager;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy