container/profiles/src/main/java/org/mobicents/slee/container/deployment/profile/jpa/JPAProfileEntityFramework.java
@SuppressWarnings("unchecked")
	public Collection<ProfileEntity> findProfilesByAttribute(
			String profileTable, ProfileAttribute profileAttribute,
			Object attributeValue) {

		if (logger.isTraceEnabled()) {
			logger.trace("findProfilesByAttribute( profileTable = "
					+ profileTable + " , profileAttribute = "
					+ profileAttribute + " , attributeValue = "
					+ attributeValue + " )");
		}

		EntityManager em = getEntityManager();
		Query query = null;
		if (profileAttribute == null) {
			query = em
					.createQuery(
							"SELECT x FROM "
									+ profileEntityClassName
									+ " x WHERE x.tableName = :tableName")
					.setParameter("tableName", profileTable);
		} else {
			if (profileAttribute.isArray()) {
				query = em
						.createQuery(
								"SELECT x FROM "
										+ profileEntityClassName
										+ " x , IN (x.c"
										+ profileAttribute.getName()
										+ ") y WHERE x.tableName = :tableName AND y.string = :attrValue")
						.setParameter("tableName", profileTable).setParameter(
								"attrValue", attributeValue.toString());
			} else {
				// TODO handle Address objects in this use case, they can't be
				// binary for search
				query = em
						.createQuery(
								"SELECT x FROM "
										+ profileEntityClassName
										+ " x WHERE x.tableName = :tableName AND x.c"
										+ profileAttribute.getName()
										+ " = :attrValue").setParameter(
								"tableName", profileTable).setParameter(
								"attrValue", attributeValue);
			}
		}

		Collection<ProfileEntity> result = query.getResultList();

		/*
		if (logger.isDebugEnabled()) {
			logger.debug("findProfilesByAttribute : query = "
					+ ((org.hibernate.ejb.QueryImpl) query).getHibernateQuery().getQueryString()
					+ " , result = " + result);
		}
		*/

		return result;
	}
@SuppressWarnings("unchecked")
	public Collection<ProfileEntity> findProfilesByAttribute(
			String profileTable, ProfileAttribute profileAttribute,
			Object attributeValue) {

		if (logger.isTraceEnabled()) {
			logger.trace("findProfilesByAttribute( profileTable = "
					+ profileTable + " , profileAttribute = "
					+ profileAttribute + " , attributeValue = "
					+ attributeValue + " )");
		}

		EntityManager em = getEntityManager();
		Query query = null;
		if (profileAttribute == null) {
			query = em
					.createQuery(
							"SELECT x FROM "
									+ profileEntityClassName
									+ " x WHERE x.tableName = :tableName")
					.setParameter("tableName", profileTable);
		} else {
			if (profileAttribute.isArray()) {
				query = em
						.createQuery(
								"SELECT x FROM "
										+ profileEntityClassName
										+ " x , IN (x.c"
										+ profileAttribute.getName()
										+ ") y WHERE x.tableName = :tableName AND y.string = :attrValue")
						.setParameter("tableName", profileTable).setParameter(
								"attrValue", attributeValue.toString());
			} else {
				// TODO handle Address objects in this use case, they can't be
				// binary for search
				query = em
						.createQuery(
								"SELECT x FROM "
										+ profileEntityClassName
										+ " x WHERE x.tableName = :tableName AND x.c"
										+ profileAttribute.getName()
										+ " = :attrValue").setParameter(
								"tableName", profileTable).setParameter(
								"attrValue", attributeValue);
			}
		}

		Collection<ProfileEntity> result = query.getResultList();

		/*
		if (logger.isDebugEnabled()) {
			logger.debug("findProfilesByAttribute : query = "
					+ ((org.hibernate.ejb.QueryImpl) query).getHibernateQuery().getQueryString()
					+ " , result = " + result);
		}
		*/

		return result;
	}
/*
(non-Javadoc)

@see
org.mobicents.slee.container.component.profile.ProfileEntityFramework
#findProfilesByAttribute(java.lang.String,
org.mobicents.slee.container.component.profile.ProfileAttribute,
java.lang.Object)