com.formkiq.server.dao.AbstractDaoImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of formkiq-server Show documentation
Show all versions of formkiq-server Show documentation
Server-side integration for the FormKiQ ios application
package com.formkiq.server.dao;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.springframework.util.StringUtils;
import com.formkiq.server.domain.type.SyncDTO;
import com.formkiq.server.domain.type.SyncListDTO;
/**
* AbstractDao.
*
*/
public abstract class AbstractDaoImpl implements AbstractDao {
/** EntityManager. */
@PersistenceContext
private EntityManager entityManager;
@Override
public Blob convertToBlob(final byte[] data) {
Session session = getEntityManager().unwrap(Session.class);
Blob blob = Hibernate.getLobCreator(session).createBlob(data);
return blob;
}
/**
* Converts Query to Sync List DTO.
* @param query {@link org.hibernate.Query}
* @param lastNextToken {@link String}
* @param maxRecords int
* @return {@link SyncListDTO}
*/
@SuppressWarnings("unchecked")
protected SyncListDTO convertToSyncList(final org.hibernate.Query query,
final int lastNextToken,
final int maxRecords) {
List