List of usage examples for org.hibernate.criterion Restrictions isNull
public static Criterion isNull(String propertyName)
From source file:com.emergya.persistenceGeo.dao.impl.FolderEntityDaoHibernateImpl.java
License:Open Source License
@Override public AbstractFolderEntity findRootByUser(Long idUser) { return (AbstractFolderEntity) getSession().createCriteria(persistentClass) .add(Restrictions.isNull("parent")).createAlias("user", "user") .add(Restrictions.eq("user.id", idUser)).uniqueResult(); }
From source file:com.emergya.persistenceGeo.dao.impl.FolderEntityDaoHibernateImpl.java
License:Open Source License
@Override public AbstractFolderEntity findRootByGroup(Long idGroup) { return (AbstractFolderEntity) getSession().createCriteria(persistentClass) .add(Restrictions.isNull("parent")).createAlias("authority", "authority") .add(Restrictions.eq("authority.id", idGroup)).uniqueResult(); }
From source file:com.emergya.persistenceGeo.dao.impl.FolderEntityDaoHibernateImpl.java
License:Open Source License
/** * Get all channel folders filtered/* w w w . jav a 2 s . c o m*/ * * @param inZone indicates if obtain channel folders with a zone. If this parameter is null only obtain not zoned channels * @param idZone filter by zone. Obtain only channels of the zone identified by <code>idZone</code> * * @return folder list */ public List<AbstractFolderEntity> getChannelFolders(Boolean inZone, Long idZone) { Criteria criteria = getSession().createCriteria(persistentClass); //FIXME: remove this fixme when merge if (inZone != null) { if (inZone) { criteria.add(Restrictions.isNotNull(ZONE)); } else { criteria.add(Restrictions.isNull(ZONE)); } } if (idZone != null) { criteria.createAlias(ZONE, ZONE).add(Restrictions.eq(ZONE + ".id", idZone)); } // only parent folders criteria.add(Restrictions.isNull(PARENT)); return criteria.list(); }
From source file:com.emergya.persistenceGeo.dao.impl.FolderEntityDaoHibernateImpl.java
License:Open Source License
/** * Get a folders list by zones with an specific parent. If zoneId is NULL * returns all the folder not associated to any zone. If parentId is NULL * the returned folders are root folders. * * @params <code>zoneId</code> * @params <code>parentId</code> * * @return Entities list associated with the zoneId or null if not found *///from w w w.j av a 2s. c om @Override public List<AbstractFolderEntity> findByZone(Long zoneId, Long parentId) { List<AbstractFolderEntity> folderList = new LinkedList<AbstractFolderEntity>(); Criteria criteria = getSession().createCriteria(persistentClass).createAlias("zone", "zone") .add(Restrictions.eq("zone.id", zoneId)); if (parentId == null) { criteria.add(Restrictions.isNull("parent")); } else { criteria.createAlias("parent", "parent"); criteria.add(Restrictions.eq("parent.id", parentId)); } folderList.addAll(criteria.list()); return folderList; }
From source file:com.emergya.persistenceGeo.dao.impl.FolderEntityDaoHibernateImpl.java
License:Open Source License
/** * Get all channel folders filtered//from w w w . ja va2s. c o m * * @param inZone indicates if obtain channel folders with a zone. If this parameter is null only obtain not zoned channels * @param idZone filter by zone. Obtain only channels of the zone identified by <code>idZone</code> * @param <code>isEnabled</code> * * @return folder list */ public List<AbstractFolderEntity> getChannelFolders(Boolean inZone, Long idZone, Boolean isEnable) { Criteria criteria = getSession().createCriteria(persistentClass); //FIXME: remove this fixme when merge if (inZone != null) { if (inZone) { criteria.add(Restrictions.isNotNull(ZONE)); } else { criteria.add(Restrictions.isNull(ZONE)); } } if (idZone != null) { criteria.createAlias(ZONE, ZONE).add(Restrictions.eq(ZONE + ".id", idZone)); } if (isEnable != null && isEnable) { criteria.add(Restrictions.eq("enabled", isEnable)); } else if (isEnable != null) { Disjunction dis = Restrictions.disjunction(); dis.add(Restrictions.isNull("enabled")); dis.add(Restrictions.eq("enabled", Boolean.FALSE)); criteria.add(dis); } // only parent folders criteria.add(Restrictions.isNull(PARENT)); criteria.addOrder(Order.asc("name")); return criteria.list(); }
From source file:com.emergya.persistenceGeo.dao.impl.FolderEntityDaoHibernateImpl.java
License:Open Source License
/** * Get a folders list by zones. If zoneId is NULL returns all the * folder not associated to any zone./*www .ja v a2 s. co m*/ * * @param <code>zoneId</code> * @param <code>isEnabled</code> * * @return Entities list associated with the zoneId or null if not found */ public List<AbstractFolderEntity> findByZone(Long zoneId, Boolean isEnable) { List<AbstractFolderEntity> folderList = new LinkedList<AbstractFolderEntity>(); Criteria criteria = getSession().createCriteria(persistentClass).createAlias("zone", "zone") .add(Restrictions.eq("zone.id", zoneId)); if (isEnable != null && isEnable) { criteria.add(Restrictions.eq("enabled", isEnable)); } else if (isEnable != null) { Disjunction dis = Restrictions.disjunction(); dis.add(Restrictions.isNull("enabled")); dis.add(Restrictions.eq("enabled", Boolean.FALSE)); criteria.add(dis); } folderList.addAll(criteria.list()); return folderList; }
From source file:com.emergya.persistenceGeo.dao.impl.FolderEntityDaoHibernateImpl.java
License:Open Source License
/** * Get a folders list by zones with an specific parent. If zoneId is NULL * returns all the folder not associated to any zone. If parentId is NULL * the returned folders are root folders. * * @param <code>zoneId</code> * @param <code>parentId</code> * @param <code>isEnabled</code> * * @return Entities list associated with the zoneId or null if not found *///from w w w . jav a 2s.c om public List<AbstractFolderEntity> findByZone(Long zoneId, Long parentId, Boolean isEnable) { List<AbstractFolderEntity> folderList = new LinkedList<AbstractFolderEntity>(); Criteria criteria = getSession().createCriteria(persistentClass); if (zoneId != null) { criteria.createAlias("zone", "zone").add(Restrictions.eq("zone.id", zoneId)); } if (parentId == null) { criteria.add(Restrictions.isNull("parent")); } else { criteria.createAlias("parent", "parent"); criteria.add(Restrictions.eq("parent.id", parentId)); } if (isEnable != null && isEnable) { criteria.add(Restrictions.eq("enabled", isEnable)); } else if (isEnable != null) { Disjunction dis = Restrictions.disjunction(); dis.add(Restrictions.isNull("enabled")); dis.add(Restrictions.eq("enabled", Boolean.FALSE)); criteria.add(dis); } folderList.addAll(criteria.list()); return folderList; }
From source file:com.emergya.persistenceGeo.dao.impl.LayerEntityDaoHibernateImpl.java
License:Open Source License
/** * Get a layers list by authority/*from w w w.j a v a 2s . co m*/ * * @param <code>id</code> * * @param <code>isChannel</code> compare with entity property and filter by this. False value get null values too * * @return Entities list associated with the identifier or null if not found */ public List<AbstractLayerEntity> findByAuthorityId(Long id, Boolean isChannel) { Criteria criteria = getSession().createCriteria(persistentClass).createAlias("auth", "auth") .add(Restrictions.eq("auth.id", id)); if (isChannel == null) { criteria.add(Restrictions.isNull("isChannel")); } else if (isChannel) { criteria.add(Restrictions.eq("isChannel", isChannel)); } else { Disjunction dis = Restrictions.disjunction(); dis.add(Restrictions.isNull("isChannel")); dis.add(Restrictions.eq("isChannel", isChannel)); criteria.add(dis); } return criteria.list(); }
From source file:com.emergya.persistenceGeo.dao.impl.LayerEntityDaoHibernateImpl.java
License:Open Source License
/** * Get a layers list by authority/*from w w w. j av a 2s.c o m*/ * * @param <code>id</code> * @param <code>isChannel</code> compare with entity property and filter by this. False value get null values too * * @return Entities list associated with the identifier or null if not found */ public List<AbstractLayerEntity> getLayersByFolder(Long folderId, Boolean isChannel) { Criteria criteria = getSession().createCriteria(persistentClass).createAlias("folder", "folder") .add(Restrictions.eq("folder.id", folderId)); if (isChannel == null) { criteria.add(Restrictions.isNull("isChannel")); } else if (isChannel) { criteria.add(Restrictions.eq("isChannel", isChannel)); } else { Disjunction dis = Restrictions.disjunction(); dis.add(Restrictions.isNull("isChannel")); dis.add(Restrictions.eq("isChannel", isChannel)); criteria.add(dis); } return criteria.list(); }
From source file:com.emergya.persistenceGeo.dao.impl.LayerEntityDaoHibernateImpl.java
License:Open Source License
/** * Get layers by folder/*from w w w . ja v a2s .c o m*/ * * @param folderId * @param isChannel * @param isEnabled * * @return all layers in a folder mark as channel */ public List<AbstractLayerEntity> getLayersByFolder(Long folderId, Boolean isChannel, Boolean isEnabled) { Criteria criteria = getSession().createCriteria(persistentClass).createAlias("folder", "folder") .add(Restrictions.eq("folder.id", folderId)); if (isChannel != null) { if (isChannel) { criteria.add(Restrictions.eq("isChannel", isChannel)); } else { Disjunction dis = Restrictions.disjunction(); dis.add(Restrictions.isNull("isChannel")); dis.add(Restrictions.eq("isChannel", isChannel)); criteria.add(dis); } } if (isEnabled == null) { criteria.add(Restrictions.isNull("enabled")); } else if (isEnabled) { criteria.add(Restrictions.eq("enabled", isEnabled)); } else { Disjunction dis = Restrictions.disjunction(); dis.add(Restrictions.isNull("enabled")); dis.add(Restrictions.eq("enabled", isEnabled)); criteria.add(dis); } return criteria.list(); }