@Deprecated @Override public List<?> findByNamedParam(String queryString, String paramName, Object value) throws DataAccessException { return findByNamedParam(queryString, new String[] {paramName}, new Object[] {value}); }
@Deprecated @Override public List<?> findByNamedParam(String queryString, String paramName, Object value) throws DataAccessException { return findByNamedParam(queryString, new String[] {paramName}, new Object[] {value}); }
@Deprecated @Override @SuppressWarnings({"rawtypes", "unchecked", "deprecation"}) public List<?> findByNamedParam(final String queryString, final String[] paramNames, final Object[] values) throws DataAccessException { if (paramNames.length != values.length) { throw new IllegalArgumentException("Length of paramNames array must match length of values array"); } return nonNull(executeWithNativeSession((HibernateCallback<List<?>>) session -> { org.hibernate.Query queryObject = queryObject( ReflectionUtils.invokeMethod(createQueryMethod, session, queryString)); prepareQuery(queryObject); for (int i = 0; i < values.length; i++) { applyNamedParameterToQuery(queryObject, paramNames[i], values[i]); } return queryObject.list(); })); }
@Test public void testCreateWithException() { OrgPerson person = new OrgPerson(); person.setId(new Integer(2)); person.setDescription("some description"); person.setFullname("Some testperson"); person.setLastname("testperson"); person.setCountry("Sweden"); person.setCompany("company1"); try { dummyDao.createWithException(person); fail("DummyException expected"); } catch (DummyException expected) { assertThat(true).isTrue(); } log.debug("Verifying result"); // Verify that no entry was created in ldap or hibernate db try { ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden"); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } List result = hibernateTemplate.findByNamedParam("from OrgPerson person where person.lastname = :lastname", "lastname", person.getLastname()); assertThat(result.size() == 0).isTrue(); }
@Test public void testCreateWithException() { OrgPerson person = new OrgPerson(); person.setId(new Integer(2)); person.setDescription("some description"); person.setFullname("Some testperson"); person.setLastname("testperson"); person.setCountry("Sweden"); person.setCompany("company1"); try { dummyDao.createWithException(person); fail("DummyException expected"); } catch (DummyException expected) { assertThat(true).isTrue(); } log.debug("Verifying result"); // Verify that no entry was created in ldap or hibernate db try { ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden"); fail("NameNotFoundException expected"); } catch (NameNotFoundException expected) { assertThat(true).isTrue(); } List result = hibernateTemplate.findByNamedParam("from OrgPerson person where person.lastname = :lastname", "lastname", person.getLastname()); assertThat(result.size() == 0).isTrue(); }