26 lines
658 B
Java
26 lines
658 B
Java
package dev.hinterdorfer;
|
|
|
|
import jakarta.enterprise.context.ApplicationScoped;
|
|
import jakarta.inject.Inject;
|
|
import jakarta.persistence.EntityManager;
|
|
|
|
import java.util.Collection;
|
|
|
|
@ApplicationScoped
|
|
public class FlowerPersistance {
|
|
@Inject
|
|
private EntityManager em;
|
|
|
|
public Collection<FlowerEntity> find (final Color color) {
|
|
return em.createNamedQuery("FlowerEntity.findByColor", FlowerEntity.class)
|
|
.setParameter("color", color)
|
|
.getResultList();
|
|
}
|
|
|
|
public long count() {
|
|
return em.createNamedQuery("FlowerEntity.countAll", Long.class)
|
|
.getSingleResult();
|
|
}
|
|
|
|
}
|