agave-profiles/profiles-core/src/main/java/org/iplantc/service/profile/dao/InternalUserDao.java
/**
	 * Search for internal users with a value containing <code>value</code> within the
	 * column defined by <code>field</code> for the given API user.
	 *  
	 * @param apiUsername
	 * @param field
	 * @param value
	 * @return
	 * @throws ProfileException
	 */
Search for internal users with a value containing value within the
column defined by field for the given API user.


Search for internal users with a value containing value within the column defined by field for the given API user .
@SuppressWarnings("unchecked")
	public List<InternalUser> findByExample(String apiUsername, String field, Object value)
	throws ProfileException
	{
		try
		{
			Session session = getSession();
			Criteria criteria = session.createCriteria(InternalUser.class);
			if (value instanceof Boolean) {
				criteria.add(Restrictions.eq(field, value));
			} else {
				if (field.equalsIgnoreCase("name")) {
					String where = "CONCAT(lower({alias}.first_name), ' ', lower({alias}.last_name)) like ?";
					criteria.add(Restrictions.sqlRestriction(where, "%" + ((String)value).toLowerCase() + "%", org.hibernate.type.StandardBasicTypes.STRING ));
				} else {
					criteria.add(Restrictions.ilike(field, "%" + value + "%"));
				}
			}
			criteria.add(Restrictions.eq("createdBy", apiUsername));
			List<InternalUser> users = criteria.list();
			session.flush();
			return users;
		}
		catch (HibernateException ex)
		{
			try
			{
				if (HibernateUtil.getSession().isOpen()) {
					HibernateUtil.rollbackTransaction();
				}
			}
			catch (Exception e) {}
			throw new ProfileException(ex);
		}
		finally {
			try { HibernateUtil.commitTransaction(); } catch (Exception e) {}
		}
	}
@ SuppressWarnings ( "unchecked" ) public List < InternalUser > findByExample ( String apiUsername , String field , Object value ) throws ProfileException { try { Session session = getSession ( ) ; Criteria criteria = session . createCriteria ( InternalUser . class ) ; if ( value instanceof Boolean ) { criteria . add ( Restrictions . eq ( field , value ) ) ; } else { if ( field . equalsIgnoreCase ( "name" ) ) { String where = "CONCAT(lower({alias}.first_name), ' ', lower({alias}.last_name)) like ?" ; criteria . add ( Restrictions . sqlRestriction ( where , "%" + ( ( String ) value ) . toLowerCase ( ) + "%" , org . hibernate . type . StandardBasicTypes . STRING ) ) ; } else { criteria . add ( Restrictions . ilike ( field , "%" + value + "%" ) ) ; } } criteria . add ( Restrictions . eq ( "createdBy" , apiUsername ) ) ; List < InternalUser > users = criteria . list ( ) ; session . flush ( ) ; return users ; } catch ( HibernateException ex ) { try { if ( HibernateUtil . getSession ( ) . isOpen ( ) ) { HibernateUtil . rollbackTransaction ( ) ; } } catch ( Exception e ) { } throw new ProfileException ( ex ) ; } finally { try { HibernateUtil . commitTransaction ( ) ; } catch ( Exception e ) { } } }
Search for internal users with a value containing <code>value</code> within the
 column defined by <code>field</code> for the given API user.
Search for internal users with a value containing <code > value< / code > within the column defined by <code > field< / code > for the given API user .
//			String hql = "from InternalUser u " + //					"where u.createdBy = :createdby " + //					//"and u.active = :active " +  //					"and u." + field + " like '%" + value + "%'";