Example usage for org.hibernate.type StandardBasicTypes STRING

List of usage examples for org.hibernate.type StandardBasicTypes STRING

Introduction

In this page you can find the example usage for org.hibernate.type StandardBasicTypes STRING.

Prototype

StringType STRING

To view the source code for org.hibernate.type StandardBasicTypes STRING.

Click Source Link

Document

The standard Hibernate type for mapping String to JDBC java.sql.Types#VARCHAR VARCHAR .

Usage

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.OrganizationSettingRepositoryHibernate.java

License:Open Source License

@Override
@Cacheable("persistent")
public String getOrganizationSetting(String key, String organizationUid) {
    Query query = getSessionReadOnly().createSQLQuery(GET_ORGANIZATION_SETTING).addScalar(VALUE,
            StandardBasicTypes.STRING);
    query.setParameter(ORG_UID_PARAM, organizationUid);
    query.setParameter(NAME, key);//from  w ww.j a v  a2 s .  c om
    List<String> results = query.list();
    if (results != null && results.size() > 0) {
        return results.get(0);
    }
    return null;
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.partner.CustomFieldRepositoryHibernate.java

License:Open Source License

private List<Object[]> getAllCustomFields(String accountUId, String searchAlias) {
    String sql = "SELECT data_column_name, name, group_code  FROM  custom_fields WHERE ";
    if (accountUId != null) {
        sql += " organization_uid =?";
    }/*from  w  ww . j a v a2s.c o m*/
    if (accountUId != null && searchAlias != null) {
        sql += " AND ";
    }
    if (searchAlias != null) {
        sql += " search_alias_name=? AND add_to_search=?";
    }
    if ((accountUId != null || searchAlias != null)) {
        sql += " AND ";
    }
    sql += " show_in_response=?";

    SQLQuery query = getSession().createSQLQuery(sql);

    int currentParameter = 0;
    if (accountUId != null) {
        query.setParameter(currentParameter, accountUId, StandardBasicTypes.STRING);
        currentParameter++;
    }
    if (searchAlias != null) {
        query.setParameter(currentParameter, searchAlias, StandardBasicTypes.STRING);
        query.setParameter(currentParameter + 1, 1, StandardBasicTypes.INTEGER);
        currentParameter++;
    }
    query.setParameter(currentParameter, 1, StandardBasicTypes.INTEGER);
    return query.list();
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.partner.CustomFieldRepositoryHibernate.java

License:Open Source License

@Override
public int checkIfCustomFieldAlreadyInserted(String resourceGooruOId) {
    String sql = "SELECT resource_gooru_oid FROM custom_fields_data WHERE resource_gooru_oid=?";
    SQLQuery query = getSession().createSQLQuery(sql);

    if (resourceGooruOId != null) {
        query.setParameter(0, resourceGooruOId, StandardBasicTypes.STRING);
    }//from   w ww. j  ava  2 s  . c  o m
    if (query.list().size() > 0) {
        return 1;
    }
    return 0;
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.partner.CustomFieldRepositoryHibernate.java

License:Open Source License

private List<String> getCustomFieldsData(String fields, String resourceId, boolean eleminateNullValue) {
    String sql = " SELECT " + fields + " FROM custom_fields_data ";
    if (resourceId != null) {
        sql += " WHERE resource_gooru_oid=?";
    }//from w  w  w  . j a  v  a2  s .  com
    SQLQuery query = getSession().createSQLQuery(sql);

    if (resourceId != null) {
        query.setParameter(0, resourceId, StandardBasicTypes.STRING);
    }

    List<Object[]> customFieldDataList = query.list();
    List<String> customFieldValues = new ArrayList<String>();
    if (customFieldDataList.size() > 0) {
        for (Object[] dataRow : customFieldDataList) {
            for (int fieldIndex = 0; fieldIndex < dataRow.length; fieldIndex++) {
                if (eleminateNullValue) {
                    if (dataRow[fieldIndex] != null) {
                        customFieldValues.add((String) dataRow[fieldIndex]);
                    }
                } else {
                    customFieldValues.add((String) dataRow[fieldIndex]);
                }
            }
        }
    }
    return customFieldValues;

}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.partner.CustomFieldRepositoryHibernate.java

License:Open Source License

@Override
public List<Object[]> getSearchAliasByOrganization(String accountUId) {
    String sql = "SELECT search_alias_name, data_column_name,add_to_search,add_to_search_index,add_to_filters FROM custom_fields WHERE show_in_response=? AND account_uid =? AND add_to_search=? ";
    SQLQuery query = getSession().createSQLQuery(sql);
    query.setParameter(0, 1, StandardBasicTypes.INTEGER);

    if (accountUId != null) {
        query.setParameter(1, accountUId, StandardBasicTypes.STRING);
    }/*  ww w  .ja va 2 s  . c  om*/
    query.setParameter(2, 1, StandardBasicTypes.INTEGER);

    query.addScalar("search_alias_name", StandardBasicTypes.STRING);
    query.addScalar("data_column_name", StandardBasicTypes.STRING);
    query.addScalar("add_to_search", StandardBasicTypes.INTEGER);
    query.addScalar("add_to_search_index", StandardBasicTypes.INTEGER);
    query.addScalar("add_to_filters", StandardBasicTypes.INTEGER);
    return query.list();
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.party.UserGroupRepositoryHibernate.java

License:Open Source License

@Override
public List<String> classMemberSuggest(String queryText, String gooruUid) {
    String hql = "select distinct(external_id)  as mailId from classpage c inner join user_group u on u.user_group_code = c.classpage_code inner join content cc on cc.content_id = classpage_content_id  inner join  user_group_association ug on ug.user_group_uid = u.user_group_uid inner join identity i on i.user_uid = ug.gooru_uid  where cc.user_uid=:gooruUid  and external_id like '"
            + queryText.replace("'", "\\") + "%'";
    Query query = getSession().createSQLQuery(hql).addScalar("mailId", StandardBasicTypes.STRING);
    query.setParameter("gooruUid", gooruUid);
    return query.list();
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.PartyRepositoryHibernate.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from   www. j a  va 2  s.co  m
public List<Map<Object, Object>> getPartyDetails() {
    String sql = " select p.party_uid as gooruUId, u.username as username, p.display_name as displayName, u.organization_uid as organizationUid  from party p inner join user u on p.party_uid = u.gooru_uid inner join party_custom_field pc on pc.party_uid= u.gooru_uid  where p.is_partner = 1 and pc.optional_key = 'sequence'  order by cast(pc.optional_value as SIGNED )";
    Query query = getSession().createSQLQuery(sql).addScalar(GOORU_UID, StandardBasicTypes.STRING)
            .addScalar(USER_NAME, StandardBasicTypes.STRING).addScalar(DISPLAY_NAME, StandardBasicTypes.STRING)
            .addScalar("organizationUid", StandardBasicTypes.STRING);
    return getPartyDetails(query.list());
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.task.TaskRepositoryHibernate.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/* w  ww.jav a  2  s .  co m*/
public List<Map<Object, Object>> getCollectionClasspageAssoc(String collectionId, String gooruUid) {
    Session session = getSession();
    String sql = "select car.title as title, cor.gooru_oid as classpageId from classpage cc inner join resource car on car.content_id = cc.classpage_content_id inner join content cor on cor.content_id = car.content_id   inner join collection_item ci on cc.classpage_content_id = ci.collection_content_id inner join content c on c.content_id = ci.collection_content_id inner join resource r on  r.content_id = ci.resource_content_id inner join content cr on cr.content_id = r.content_id where cr.gooru_oid='"
            + collectionId + "'";
    if (gooruUid != null) {
        sql += "and ci.associated_by_uid='" + gooruUid + "'";
    }
    Query query = session.createSQLQuery(sql).addScalar("title", StandardBasicTypes.STRING)
            .addScalar("classpageId", StandardBasicTypes.STRING);
    return getClasspageData(query.list());
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.taxonomy.TaxonomyRepositoryHibernate.java

License:Open Source License

@Override
@Cacheable("gooruCache")
public String getFindTaxonomyList(String excludeCode) {
    String hql = "select group_concat(code_id) as codes from code where depth = 0 and organization_uid  IN ("
            + getUserOrganizationUidsAsString() + ") and code_id not in (" + excludeCode + ")";
    Query query = getSession().createSQLQuery(hql).addScalar("codes", StandardBasicTypes.STRING);
    return (String) query.list().get(0);
}

From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.taxonomy.TaxonomyRepositoryHibernate.java

License:Open Source License

@Cacheable("gooruCache")
@Override//from w ww  .j  a  v  a 2 s .co m
public String getFindTaxonomyCodeList(String codeIds) {
    String hql = "select group_concat(code) as codes from code where depth = 0 and organization_uid  IN ("
            + getUserOrganizationUidsAsString() + ") and code_id  in (" + codeIds + ")";
    Query query = getSession().createSQLQuery(hql).addScalar("codes", StandardBasicTypes.STRING);
    return (String) query.list().get(0);
}