Search in sources :

Example 31 with NoResultException

use of javax.persistence.NoResultException in project webpieces by deanhiller.

the class UserDbo method findWithJoin.

public static UserDbo findWithJoin(EntityManager mgr, int id) {
    Query query = mgr.createNamedQuery("findByIdWithRoleJoin");
    query.setParameter("id", id);
    try {
        return (UserDbo) query.getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}
Also used : Query(javax.persistence.Query) NamedQuery(javax.persistence.NamedQuery) NoResultException(javax.persistence.NoResultException)

Example 32 with NoResultException

use of javax.persistence.NoResultException in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_DistinctionsTest method testDeleteDistinction.

@Test
public void testDeleteDistinction() {
    SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewDistinction("0000-0000-0000-0002", 1000L);
    assertNotNull(response);
    Distinction distinction = (Distinction) response.getEntity();
    assertNotNull(distinction);
    response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1000L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    try {
        serviceDelegator.viewDistinction("0000-0000-0000-0002", 1000L);
        fail();
    } catch (NoResultException nre) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) NoResultException(javax.persistence.NoResultException) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 33 with NoResultException

use of javax.persistence.NoResultException in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_EmploymentsTest method testDeleteEmployment.

@Test
public void testDeleteEmployment() {
    SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEmployment("0000-0000-0000-0002", 1002L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1002L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    try {
        serviceDelegator.viewEmployment("0000-0000-0000-0002", 1002L);
        fail();
    } catch (NoResultException nre) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) NoResultException(javax.persistence.NoResultException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 34 with NoResultException

use of javax.persistence.NoResultException in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testDeleteInvitedPosition.

@Test
public void testDeleteInvitedPosition() {
    SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewInvitedPosition("0000-0000-0000-0002", 1003L);
    assertNotNull(response);
    InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1003L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    try {
        serviceDelegator.viewInvitedPosition("0000-0000-0000-0002", 1003L);
        fail();
    } catch (NoResultException nre) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) NoResultException(javax.persistence.NoResultException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 35 with NoResultException

use of javax.persistence.NoResultException in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_MembershipsTest method testDeleteMembership.

@Test
public void testDeleteMembership() {
    SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewMembership("0000-0000-0000-0002", 1004L);
    assertNotNull(response);
    Membership membership = (Membership) response.getEntity();
    assertNotNull(membership);
    response = serviceDelegator.deleteAffiliation("0000-0000-0000-0002", 1004L);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    try {
        serviceDelegator.viewMembership("0000-0000-0000-0002", 1004L);
        fail();
    } catch (NoResultException nre) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) NoResultException(javax.persistence.NoResultException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

NoResultException (javax.persistence.NoResultException)356 Query (javax.persistence.Query)205 EntityManager (javax.persistence.EntityManager)69 NonUniqueResultException (javax.persistence.NonUniqueResultException)33 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)25 TypedQuery (javax.persistence.TypedQuery)22 Transactional (org.springframework.transaction.annotation.Transactional)20 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)19 Test (org.junit.Test)17 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)15 Session (org.hibernate.Session)13 UnitOfWork (com.google.inject.persist.UnitOfWork)12 Project (de.tudarmstadt.ukp.clarin.webanno.model.Project)11 PersistenceException (javax.persistence.PersistenceException)11 Date (java.util.Date)9 NotFoundException (org.opencastproject.util.NotFoundException)9 TblMle (com.intel.mtwilson.as.data.TblMle)8 List (java.util.List)8 NamedQuery (javax.persistence.NamedQuery)8