List of usage examples for org.springframework.dao.support DataAccessUtils singleResult
@Nullable public static <T> T singleResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException
From source file:nl.conspect.legacy.repository.impl.HibernateUserRepositoryImpl.java
public User findWithUsername(String username) { String hql = "from User u where u.username=:username"; List users = getHibernateTemplate().findByNamedParam(hql, "username", username); return (User) DataAccessUtils.singleResult(users); }
From source file:eu.domibus.common.dao.MessagingDao.java
public UserMessage findUserMessageByMessageId(final String messageId) { final TypedQuery<UserMessage> query = this.em.createNamedQuery("Messaging.findUserMessageByMessageId", UserMessage.class); query.setParameter("MESSAGE_ID", messageId); return DataAccessUtils.singleResult(query.getResultList()); }
From source file:org.apereo.services.persondir.support.BasePersonAttributeDao.java
@Override public final Map<String, List<Object>> getMultivaluedUserAttributes(final Map<String, List<Object>> seed) { final Set<IPersonAttributes> people = this.getPeopleWithMultivaluedAttributes(seed); //Get the first IPersonAttributes to return data for final IPersonAttributes person = DataAccessUtils.singleResult(people); //If null or no results return null if (person == null) { return null; }// ww w.jav a2 s . co m //Make a mutable copy of the person's attributes return new LinkedHashMap<>(person.getAttributes()); }
From source file:eu.domibus.common.dao.MessagingDao.java
public SignalMessage findSignalMessageByMessageId(final String messageId) { final TypedQuery<SignalMessage> query = this.em.createNamedQuery("Messaging.findSignalMessageByMessageId", SignalMessage.class); query.setParameter("MESSAGE_ID", messageId); return DataAccessUtils.singleResult(query.getResultList()); }
From source file:org.jasig.portlet.blackboardvcportlet.service.impl.RecordingServiceImpl.java
@Override public void updateSessionRecordings(long sessionId, long startTime, long endTime) { //fetch the recording long information from the web service List<BlackboardRecordingLongResponse> recordingLongList = recordingWSDao.getRecordingLong(null, null, sessionId, null, startTime, endTime, null); BlackboardRecordingLongResponse recordingResponse = DataAccessUtils.singleResult(recordingLongList); //post the information to the database recordingDao.createOrUpdateRecording(recordingResponse); }
From source file:org.apereo.services.persondir.support.BasePersonAttributeDao.java
@Override public final Map<String, Object> getUserAttributes(final Map<String, Object> seed) { final Set<IPersonAttributes> people = this.getPeople(seed); //Get the first IPersonAttributes to return data for final IPersonAttributes person = DataAccessUtils.singleResult(people); //If null or no results return null if (person == null) { return null; }//from ww w .ja v a 2 s. c o m final Map<String, List<Object>> multivaluedUserAttributes = new LinkedHashMap<>(person.getAttributes()); return this.flattenResults(multivaluedUserAttributes); }
From source file:com.buession.cas.service.persondir.support.jdbc.OAuthSingleRowJdbcPersonAttributeDao.java
@Override public IPersonAttributes getPerson(String uid) { Validate.notNull(uid, "uid may not be null."); // Generate the ProviderId map for the uid final ProviderId providerId = convertAttributesMap(uid); // Run the query using the seed final Set<IPersonAttributes> people = getPeopleProvider(providerId); // Ensure a single result is returned IPersonAttributes person = DataAccessUtils.singleResult(people); if (person == null) { return null; }//from w w w .j a v a 2 s . c om // Force set the name of the returned IPersonAttributes if it isn't provided in the return // object if (person.getName() == null) { person = new NamedPersonImpl(uid, person.getAttributes()); } return person; }
From source file:io.github.huherto.springyRecords.BaseTable.java
/** * @return null if the object is not found. *///from w ww.j a va 2 s. c o m protected R queryForObjectOrNull(String sql, Object... args) { List<R> results = query(sql, args, new RowMapperResultSetExtractor<R>(rowMapper(), 1)); return DataAccessUtils.singleResult(results); }
From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.GlobalSettingsWSDaoImpl.java
@Override public BlackboardServerConfigurationResponse getServerConfiguration() { final JAXBElement<BlackboardServerConfiguration> request = new ObjectFactory() .createGetServerConfiguration(null); BlackboardGetServerConfigurationResponseCollection responseCollection = (BlackboardGetServerConfigurationResponseCollection) sasWebServiceTemplate .marshalSendAndReceiveToSAS("http://sas.elluminate.com/GetServerConfiguration", request); List<BlackboardServerConfigurationResponse> configResult = responseCollection .getServerConfigurationResponses(); return DataAccessUtils.singleResult(configResult); }