use of fi.otavanopisto.muikku.plugins.material.coops.model.HtmlMaterialRevisionProperty in project muikku by otavanopisto.
the class HtmlMaterialRevisionPropertyDAO method findByHtmlMaterialAndKeyRevisionLeAndMaxRevision.
public HtmlMaterialRevisionProperty findByHtmlMaterialAndKeyRevisionLeAndMaxRevision(HtmlMaterial htmlMaterial, String key, Long revisionLe) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<HtmlMaterialRevisionProperty> criteria = criteriaBuilder.createQuery(HtmlMaterialRevisionProperty.class);
Root<HtmlMaterialRevisionProperty> root = criteria.from(HtmlMaterialRevisionProperty.class);
Join<HtmlMaterialRevisionProperty, HtmlMaterialRevision> revisionJoin = root.join(HtmlMaterialRevisionProperty_.htmlMaterialRevision);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(HtmlMaterialRevisionProperty_.key), key), criteriaBuilder.equal(revisionJoin.get(HtmlMaterialRevision_.htmlMaterial), htmlMaterial), criteriaBuilder.lessThanOrEqualTo(revisionJoin.get(HtmlMaterialRevision_.revision), revisionLe)));
// TODO: This could be optimized
criteria.orderBy(criteriaBuilder.desc(revisionJoin.get(HtmlMaterialRevision_.revision)));
TypedQuery<HtmlMaterialRevisionProperty> query = entityManager.createQuery(criteria);
query.setMaxResults(1);
return getSingleResult(query);
}
use of fi.otavanopisto.muikku.plugins.material.coops.model.HtmlMaterialRevisionProperty in project muikku by otavanopisto.
the class HtmlMaterialRevisionPropertyDAO method create.
public HtmlMaterialRevisionProperty create(HtmlMaterialRevision htmlMaterialRevision, String key, String value) {
HtmlMaterialRevisionProperty htmlMaterialRevisionProperty = new HtmlMaterialRevisionProperty();
htmlMaterialRevisionProperty.setFileRevision(htmlMaterialRevision);
htmlMaterialRevisionProperty.setValue(value);
htmlMaterialRevisionProperty.setKey(key);
return persist(htmlMaterialRevisionProperty);
}
Aggregations