List of usage examples for org.hibernate.type StandardBasicTypes LONG
LongType LONG
To view the source code for org.hibernate.type StandardBasicTypes LONG.
Click Source Link
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.CollectionRepositoryHibernate.java
License:Open Source License
@Override public Long getFolderListCount(String gooruOid, String title, String gooruUid) { String sql = "select count(1) as count from resource r inner join collection c on r.content_id = c.content_id inner join content cc on c.content_id = cc.content_id inner join user u on cc.user_uid = u.gooru_uid where c.collection_type = 'folder'"; if (gooruOid != null) { sql += " and cc.gooru_oid = '" + gooruOid + "'"; }//from www . ja v a 2 s. c o m if (title != null) { sql += " and r.title = '" + title + "'"; } if (gooruUid != null) { sql += " and u.gooru_uid = '" + gooruUid + "'"; } Query query = getSession().createSQLQuery(sql).addScalar("count", StandardBasicTypes.LONG); return (Long) query.list().get(0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.CollectionRepositoryHibernate.java
License:Open Source License
@Override public Long getCollectionCount(String publishStatus) { String sql = "SELECT count(1) as count from collection c left join custom_table_value ct on ct.custom_table_value_id = c.publish_status_id where ct.value = '" + publishStatus + "' and c.collection_type in ('collection', 'quiz')"; Query query = getSession().createSQLQuery(sql).addScalar("count", StandardBasicTypes.LONG); return (Long) query.list().get(0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.featured.FeaturedRepositoryHibernate.java
License:Open Source License
@Override public Long getLibraryCollectionCount(String themeCode, String themeType, String gooruOid, String codeId) { String sql = "select count(1) as count from code c inner join featured_set_items fs inner join featured_set f on (f.featured_set_id = fs.featured_set_id and fs.code_id = c.code_id) inner join content ct inner join collection cn on (ct.content_id = cn.content_id) inner join resource r on (cn.content_id = r.content_id and fs.content_id = r.content_id)"; if (themeCode != null && themeType != null) { sql += " where f.subject_code_id =:themeType and f.theme_code =:themeCode"; } else if (themeType != null) { sql += " where f.subject_code_id =:themeType"; } else if (themeCode != null) { sql += " where f.theme_code =:themeCode"; }/*from ww w . ja v a2 s . com*/ if (gooruOid != null) { sql += " and ct.gooru_oid ='" + gooruOid + "'"; } if (codeId != null) { sql += " and fs.code_id = '" + codeId + "'"; } Query query = getSessionReadOnly().createSQLQuery(sql).addScalar("count", StandardBasicTypes.LONG); if (themeType != null) { query.setParameter("themeType", themeType); } if (themeCode != null) { query.setParameter("themeCode", themeCode); } return (Long) query.list().get(0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.featured.FeaturedRepositoryHibernate.java
License:Open Source License
@Override public Long getLibraryResourceCount(String type, String libraryName) { String sql = "select count(*) as count from featured_set f inner join featured_set_items fsi on fsi.featured_set_id = f.featured_set_id inner join content c on c.content_id = fsi.content_id inner join collection cc on c.content_id = cc.content_id inner join collection_item ci on ci.collection_content_id = cc.content_id inner join resource r on r.content_id = ci.resource_content_id inner join content con on con.content_id = r.content_id inner join resource_source rs on r.resource_source_id = rs.resource_source_id where f.theme_code =:themeCode "; if (type != null) { sql += " and f.subject_code_id =:type"; }//from w ww . j a v a 2 s.c om Query query = getSessionReadOnly().createSQLQuery(sql).addScalar("count", StandardBasicTypes.LONG); if (type != null) { query.setParameter("type", type); } query.setParameter("themeCode", libraryName); return (Long) query.list().get(0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.FeedbackRepositoryHibernate.java
License:Open Source License
@Override public Long getContentFeedbackReviewCount(String assocGooruOid, String feedbackRatingType) { Query query = getSession().createSQLQuery(FETCH_CONTENT_FEEDBACK_REVIEW_COUNT) .addScalar("count", StandardBasicTypes.LONG).setParameter("assocGooruOid", assocGooruOid) .setParameter("feedbackRatingType", feedbackRatingType); return (Long) query.list().get(0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.index.ContentIdexDaoImpl.java
License:Open Source License
@Override public Long getSubscriptionCountByContentId(long contentId) { SQLQuery query = getSessionFactory().getCurrentSession().createSQLQuery(GET_SUBSCRIPTION_BY_CONTENT_ID); query.addScalar("subscriberCount", StandardBasicTypes.LONG); query.setLong(CONTENT_ID, contentId); List<Long> list = query.list(); return (list.size() > 0 ? list.get(0) : 0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.party.OrganizationRepositoryHibernate.java
License:Open Source License
@Override public Long getOrganizationCount(String type, String parentOrganizationUid, String sateProvinceId) { String sql = "select count(1) as count from organization o inner join custom_table_value ct on ct.custom_table_value_id = o.type_id where 1=1"; if (type != null) { sql += " AND ct.key_value = '" + type + "'"; }/*from w w w . j ava 2 s. co m*/ if (parentOrganizationUid != null) { sql += " AND parent_organization_uid = '" + parentOrganizationUid + "'"; } Query query = getSession().createSQLQuery(sql).addScalar("count", StandardBasicTypes.LONG); return (Long) query.list().get(0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.resource.ResourceRepositoryHibernate.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from ww w .j a v a 2 s.c o m*/ public List<Long> findResources(Map<String, String> filters) { String sql = "select r.content_id from resource r WHERE r.type_name not in (" + EXCLUDE_FOR_RESOURCES_STRING + ",'assessment-question')"; int pageSize = Integer.parseInt(filters.get("pageSize")); int pageNo = Integer.parseInt(filters.get("pageNo")); String batchId = filters.get("batchId"); if (batchId != null) { sql += " WHERE"; sql += " r.batch_id= " + batchId; } sql += " LIMIT " + (pageSize * (pageNo - 1)) + " , " + pageSize; SQLQuery query = getSession().createSQLQuery(sql); query.addScalar("content_id", StandardBasicTypes.LONG); List<Long> results = query.list(); return results; }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.tag.TagRepositoryHibernate.java
License:Open Source License
public Long getResourceByLabelCount(String label, String gooruUid) { String sql = "select count(1) as count from tags t inner join content c on (c.content_id = t.content_id) inner join content_tag_assoc ct on (ct.tag_gooru_oid = c.gooru_oid) inner join content ci on (ci.gooru_oid = ct.content_gooru_oid) inner join resource r on r.content_id = ci.content_id left join custom_table_value cu on cu.custom_table_value_id = r.resource_format_id where (t.label =:label or ct.tag_gooru_oid =:label) and ct.associated_uid =:gooruUid"; Query query = getSession().createSQLQuery(sql).addScalar("count", StandardBasicTypes.LONG); query.setParameter("label", label); query.setParameter("gooruUid", gooruUid); return (Long) query.list().get(0); }
From source file:org.ednovo.gooru.infrastructure.persistence.hibernate.task.TaskRepositoryHibernate.java
License:Open Source License
@Override public Long getCollectionClasspageAssocCount(String collectionId) { Session session = getSession();//from w ww. j ava 2s.com String sql = "select count(*) as count 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 + "' and ci.associated_by_uid != cr.user_uid"; Query query = session.createSQLQuery(sql).addScalar("count", StandardBasicTypes.LONG); return (Long) query.list().get(0); }