Search in sources :

Example 1 with MCRCategLinkReference_

use of org.mycore.datamodel.classifications2.MCRCategLinkReference_ in project mycore by MyCoRe-Org.

the class MCRCategLinkServiceImpl method getReferences.

@Override
public Collection<MCRCategLinkReference> getReferences(String type) {
    EntityManager em = MCREntityManagerProvider.getCurrentEntityManager();
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<MCRCategLinkReference> query = cb.createQuery(MCRCategLinkReference.class);
    Root<MCRCategoryLinkImpl> li = query.from(LINK_CLASS);
    Path<MCRCategLinkReference> objectReferencePath = li.get(MCRCategoryLinkImpl_.objectReference);
    return em.createQuery(query.select(objectReferencePath).where(cb.equal(objectReferencePath.get(MCRCategLinkReference_.type), type))).setHint(QueryHints.READ_ONLY, "true").getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) MCRCategLinkReference(org.mycore.datamodel.classifications2.MCRCategLinkReference)

Example 2 with MCRCategLinkReference_

use of org.mycore.datamodel.classifications2.MCRCategLinkReference_ in project mycore by MyCoRe-Org.

the class MCRCategLinkServiceImpl method getLinks.

@Override
public Collection<MCRCategoryLink> getLinks(String type) {
    EntityManager em = MCREntityManagerProvider.getCurrentEntityManager();
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<MCRCategoryLink> query = cb.createQuery(MCRCategoryLink.class);
    Root<MCRCategoryLinkImpl> li = query.from(LINK_CLASS);
    return em.createQuery(query.where(cb.equal(li.get(MCRCategoryLinkImpl_.objectReference).get(MCRCategLinkReference_.type), type))).setHint(QueryHints.READ_ONLY, "true").getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) MCRCategoryLink(org.mycore.datamodel.classifications2.MCRCategoryLink)

Aggregations

EntityManager (javax.persistence.EntityManager)2 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)2 MCRCategLinkReference (org.mycore.datamodel.classifications2.MCRCategLinkReference)1 MCRCategoryLink (org.mycore.datamodel.classifications2.MCRCategoryLink)1