Search in sources :

Example 6 with MasterRegistrationControlEntryEntity

use of io.joynr.accesscontrol.global.jee.persistence.MasterRegistrationControlEntryEntity in project joynr by bmwcarit.

the class MasterRegistrationControlEntryManager method findByUserIdDomainInterfaceNameOperationAndType.

private MasterRegistrationControlEntryEntity findByUserIdDomainInterfaceNameOperationAndType(String userId, String domain, String interfaceName, ControlEntryType type) {
    Query query = entityManager.createQuery("select mrce from MasterRegistrationControlEntryEntity mrce " + "where mrce.userId = :userId and mrce.domain = :domain and mrce.interfaceName = :interfaceName and mrce.type = :type", MasterRegistrationControlEntryEntity.class);
    query.setParameter("userId", userId);
    query.setParameter("domain", domain);
    query.setParameter("interfaceName", interfaceName);
    query.setParameter("type", type);
    List<MasterRegistrationControlEntryEntity> resultList = query.getResultList();
    MasterRegistrationControlEntryEntity entity = null;
    if (resultList.size() == 1) {
        entity = resultList.get(0);
    } else if (resultList.size() > 1) {
        throw new JoynrIllegalStateException(String.format("Too many results found for %s with userId / domain / interfaceName / type: %s / %s / %s / %s", MasterRegistrationControlEntryEntity.class.getSimpleName(), userId, domain, interfaceName, type));
    }
    return entity;
}
Also used : Query(javax.persistence.Query) MasterRegistrationControlEntryEntity(io.joynr.accesscontrol.global.jee.persistence.MasterRegistrationControlEntryEntity) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException)

Aggregations

MasterRegistrationControlEntryEntity (io.joynr.accesscontrol.global.jee.persistence.MasterRegistrationControlEntryEntity)6 Test (org.junit.Test)3 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)1 Query (javax.persistence.Query)1 MasterRegistrationControlEntry (joynr.infrastructure.DacTypes.MasterRegistrationControlEntry)1