org.hibernate.criterion.Expression Java Examples
The following examples show how to use
org.hibernate.criterion.Expression.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SbiMetaJobDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
@Override public SbiMetaJob loadJobByName(Session session, String name) throws EMFUserError { logger.debug("IN"); SbiMetaJob toReturn = null; Session tmpSession = session; try { Criterion labelCriterrion = Expression.eq("name", name); Criteria criteria = tmpSession.createCriteria(SbiMetaJob.class); criteria.add(labelCriterrion); toReturn = (SbiMetaJob) criteria.uniqueResult(); if (toReturn == null) return null; } catch (HibernateException he) { logException(he); throw new EMFUserError(EMFErrorSeverity.ERROR, 100); } finally { logger.debug("OUT"); } return toReturn; }
Example #2
Source File: MultiTableTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void testCriteria() throws Exception { Session s = openSession(); Transaction t = s.beginTransaction(); Lower l = new Lower(); s.save(l); assertTrue( l==s.createCriteria(Top.class).uniqueResult() ); s.delete(l); s.flush(); Criteria c = s.createCriteria(Lower.class); c.createCriteria("yetanother") .add( Expression.isNotNull("id") ) .createCriteria("another"); c.createCriteria("another").add( Expression.isNotNull("id") ); c.list(); t.commit(); s.close(); }
Example #3
Source File: SyllabusManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
/** * getSyllabiForSyllabusItem returns the collection of syllabi * @param syllabusItem */ public Set getSyllabiForSyllabusItem(final SyllabusItem syllabusItem) { if (syllabusItem == null) { throw new IllegalArgumentException("Null Argument"); } else { HibernateCallback<Set> hcb = session -> { // get syllabi in an eager fetch mode Criteria crit = session.createCriteria(SyllabusItemImpl.class) .add(Expression.eq(SURROGATE_KEY, syllabusItem.getSurrogateKey())) .setFetchMode(SYLLABI, FetchMode.EAGER); SyllabusItem syllabusItem1 = (SyllabusItem) crit.uniqueResult(); if (syllabusItem1 != null){ return syllabusItem1.getSyllabi(); } return new TreeSet(); }; return getHibernateTemplate().execute(hcb); } }
Example #4
Source File: SbiMetaBcDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
/** * Load source by the unique name. * * @param session * the session * * @param name * the unique name * * @return the meta bc * * @throws EMFUserError * the EMF user error * * @see it.eng.spagobi.metadata.dao.ISbiMetaBcDAOHibImpl#loadBcByUniqueName(session, string) */ @Override public SbiMetaBc loadBcByUniqueName(Session session, String uniqueName) throws EMFUserError { logger.debug("IN"); SbiMetaBc toReturn = null; try { Criterion labelCriterrion = Expression.eq("uniqueName", uniqueName); Criteria criteria = session.createCriteria(SbiMetaBc.class); criteria.add(labelCriterrion); toReturn = (SbiMetaBc) criteria.uniqueResult(); } catch (HibernateException he) { logException(he); throw new HibernateException(he); } finally { logger.debug("OUT"); } return toReturn; }
Example #5
Source File: SbiMetaBcDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
/** * Load source by name. * * @param session * the session * * @param name * the source name * * @return the meta source * * @throws EMFUserError * the EMF user error * * @see it.eng.spagobi.metadata.dao.ISbiMetaBcDAOHibImpl#loadBcByName(session, string) */ @Override public SbiMetaBc loadBcByName(Session session, String name) throws EMFUserError { logger.debug("IN"); SbiMetaBc toReturn = null; try { Criterion labelCriterrion = Expression.eq("name", name); Criteria criteria = session.createCriteria(SbiMetaBc.class); criteria.add(labelCriterrion); toReturn = (SbiMetaBc) criteria.uniqueResult(); } catch (HibernateException he) { logException(he); throw new HibernateException(he); } finally { logger.debug("OUT"); } return toReturn; }
Example #6
Source File: SakaiPersonManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public List isFerpaEnabled(final Collection agentUuids) { if (log.isDebugEnabled()) { log.debug("isFerpaEnabled(Set {})", agentUuids); } if (agentUuids == null || agentUuids.isEmpty()) { throw new IllegalArgumentException("Illegal Set agentUuids argument!"); } final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { final Criteria c = session.createCriteria(SakaiPersonImpl.class); c.add(Expression.in(AGENT_UUID, agentUuids)); c.add(Expression.eq(FERPA_ENABLED, Boolean.TRUE)); return c.list(); } }; return (List) getHibernateTemplate().execute(hcb); }
Example #7
Source File: StatsManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public List<SiteActivity> getSiteActivity(final String siteId, final List<String> events, final Date iDate, final Date fDate) { if(siteId == null){ throw new IllegalArgumentException("Null siteId"); }else{ HibernateCallback<List<SiteActivity>> hcb = session -> { Criteria c = session.createCriteria(SiteActivityImpl.class) .add(Expression.eq("siteId", siteId)) .add(Expression.in("eventId", events)); if(iDate != null) c.add(Expression.ge("date", iDate)); if(fDate != null){ // adjust final date Calendar ca = Calendar.getInstance(); ca.setTime(fDate); ca.add(Calendar.DAY_OF_YEAR, 1); Date fDate2 = ca.getTime(); c.add(Expression.lt("date", fDate2)); } return c.list(); }; return getHibernateTemplate().execute(hcb); } }
Example #8
Source File: SyllabusManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public Set getSyllabusAttachmentsForSyllabusData(final SyllabusData syllabusData) { if (syllabusData == null) { throw new IllegalArgumentException("Null Argument"); } else { HibernateCallback<Set<SyllabusAttachment>> hcb = session -> { Criteria crit = session.createCriteria(SyllabusDataImpl.class) .add(Expression.eq(SYLLABUS_DATA_ID, syllabusData.getSyllabusId())) .setFetchMode(ATTACHMENTS, FetchMode.EAGER); SyllabusData syllabusData1 = (SyllabusData) crit.uniqueResult(); if (syllabusData1 != null){ return syllabusData1.getAttachments(); } return new TreeSet(); }; return getHibernateTemplate().execute(hcb); } }
Example #9
Source File: RWikiCurrentObjectDaoImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public RWikiCurrentObject findByGlobalName(final String name) { long start = System.currentTimeMillis(); try { // there is no point in sorting by version, since there is only one // version in // this table. // also using like is much slower than eq HibernateCallback<List> callback = session -> session .createCriteria(RWikiCurrentObject.class) .add(Expression.eq("name", name)) .list(); List found = getHibernateTemplate().execute(callback); if (found.size() == 0) { log.debug("Found {} objects with name {}", found.size(), name); return null; } log.debug("Found {} objects with name {} returning most recent one.", found.size(), name); return (RWikiCurrentObject) proxyObject(found.get(0)); } finally { long finish = System.currentTimeMillis(); TimeLogger.printTimer("RWikiObjectDaoImpl.findByGlobalName: " + name, start, finish); } }
Example #10
Source File: GradebookManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public SortedSet getStudentGradesForGradebook(final Gradebook gradebook) throws IllegalArgumentException { if (gradebook == null) { throw new IllegalArgumentException("Null Argument"); } else { HibernateCallback hcb = session -> { // get syllabi in an eager fetch mode Criteria crit = session.createCriteria(Gradebook.class).add( Expression.eq(ID, gradebook.getId())).setFetchMode(STUDENTS, FetchMode.EAGER); Gradebook grades = (Gradebook) crit.uniqueResult(); if (grades != null) { return grades.getStudents(); } return new TreeSet(); }; return (SortedSet) getHibernateTemplate().execute(hcb); } }
Example #11
Source File: SyllabusManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public Set getSyllabusAttachmentsForSyllabusData(final SyllabusData syllabusData) { if (syllabusData == null) { throw new IllegalArgumentException("Null Argument"); } else { HibernateCallback<Set<SyllabusAttachment>> hcb = session -> { Criteria crit = session.createCriteria(SyllabusDataImpl.class) .add(Expression.eq(SYLLABUS_DATA_ID, syllabusData.getSyllabusId())) .setFetchMode(ATTACHMENTS, FetchMode.EAGER); SyllabusData syllabusData1 = (SyllabusData) crit.uniqueResult(); if (syllabusData1 != null){ return syllabusData1.getAttachments(); } return new TreeSet(); }; return getHibernateTemplate().execute(hcb); } }
Example #12
Source File: StatsManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public List<SiteVisits> getSiteVisits(final String siteId, final Date iDate, final Date fDate) { if(siteId == null){ throw new IllegalArgumentException("Null siteId"); }else{ HibernateCallback<List<SiteVisits>> hcb = session -> { Criteria c = session.createCriteria(SiteVisitsImpl.class) .add(Expression.eq("siteId", siteId)); if(iDate != null) c.add(Expression.ge("date", iDate)); if(fDate != null){ // adjust final date Calendar ca = Calendar.getInstance(); ca.setTime(fDate); ca.add(Calendar.DAY_OF_YEAR, 1); Date fDate2 = ca.getTime(); c.add(Expression.lt("date", fDate2)); } return c.list(); }; return getHibernateTemplate().execute(hcb); } }
Example #13
Source File: ChatManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public int getChannelMessagesCount(ChatChannel channel, String context, Date date) { if (channel == null) { // default to the first one List<ChatChannel> channels = getContextChannels(context, true); if (channels != null && channels.size() > 0) { channel = channels.iterator().next(); } } int count = 0; if (channel != null) { Criteria c = this.getSessionFactory().getCurrentSession().createCriteria(ChatMessage.class); c.add(Expression.eq("chatChannel", channel)); if (date != null) { c.add(Expression.ge("messageDate", date)); } c.setProjection(Projections.rowCount()); count = ((Long) c.uniqueResult()).intValue(); } return count; }
Example #14
Source File: StatsManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public List<SiteActivity> getSiteActivity(final String siteId, final List<String> events, final Date iDate, final Date fDate) { if(siteId == null){ throw new IllegalArgumentException("Null siteId"); }else{ HibernateCallback<List<SiteActivity>> hcb = session -> { Criteria c = session.createCriteria(SiteActivityImpl.class) .add(Expression.eq("siteId", siteId)) .add(Expression.in("eventId", events)); if(iDate != null) c.add(Expression.ge("date", iDate)); if(fDate != null){ // adjust final date Calendar ca = Calendar.getInstance(); ca.setTime(fDate); ca.add(Calendar.DAY_OF_YEAR, 1); Date fDate2 = ca.getTime(); c.add(Expression.lt("date", fDate2)); } return c.list(); }; return getHibernateTemplate().execute(hcb); } }
Example #15
Source File: GradebookManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public Gradebook getGradebookByTitleAndContext(final String title, final String context) { if (title == null || context == null) { throw new IllegalArgumentException("Null Argument"); } else { HibernateCallback hcb = session -> { Criteria crit = session.createCriteria(GradebookImpl.class).add( Expression.eq(TITLE, title)).add(Expression.eq(CONTEXT, context)) .setFetchMode(STUDENTS, FetchMode.EAGER); Gradebook gradebook = (Gradebook) crit.uniqueResult(); return gradebook; }; return (Gradebook) getHibernateTemplate().execute(hcb); } }
Example #16
Source File: GradebookManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public StudentGrades getStudentByGBAndUsername(final Gradebook gradebook, final String username) { if (gradebook == null || username == null) { throw new IllegalArgumentException("Null gradebookId or username passed to getStudentByGBIdAndUsername"); } HibernateCallback hcb = session -> { gradebook.setStudents(null); Criteria crit = session.createCriteria(StudentGradesImpl.class).add( Expression.eq("gradebook", gradebook)).add(Expression.eq("username", username).ignoreCase()); StudentGrades student = (StudentGrades)crit.uniqueResult(); return student; }; return (StudentGrades) getHibernateTemplate().execute(hcb); }
Example #17
Source File: FumTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void testCriteriaCollection() throws Exception { Session s = openSession(); Fum fum = new Fum( fumKey("fum") ); fum.setFum("a value"); fum.getMapComponent().getFummap().put("self", fum); fum.getMapComponent().getStringmap().put("string", "a staring"); fum.getMapComponent().getStringmap().put("string2", "a notha staring"); fum.getMapComponent().setCount(1); s.save(fum); s.flush(); s.connection().commit(); s.close(); s = openSession(); Fum b = (Fum) s.createCriteria(Fum.class).add( Expression.in("fum", new String[] { "a value", "no value" } ) ) .uniqueResult(); //assertTrue( Hibernate.isInitialized( b.getMapComponent().getFummap() ) ); assertTrue( Hibernate.isInitialized( b.getMapComponent().getStringmap() ) ); assertTrue( b.getMapComponent().getFummap().size()==1 ); assertTrue( b.getMapComponent().getStringmap().size()==2 ); s.delete(b); s.flush(); s.connection().commit(); s.close(); }
Example #18
Source File: RWikiCurrentObjectDaoImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public RWikiCurrentObject getRWikiCurrentObject(final RWikiObject reference) { long start = System.currentTimeMillis(); try { HibernateCallback<List> callback = session -> session.createCriteria(RWikiCurrentObject.class) .add(Expression.eq("id", reference.getRwikiobjectid())) .list(); List found = getHibernateTemplate().execute(callback); if (found.size() == 0) { log.debug("Found {} objects with id {}", found.size(), reference.getRwikiobjectid()); return null; } log.debug("Found {} objects with id {} returning most recent one.", found.size(), reference.getRwikiobjectid()); return (RWikiCurrentObject) proxyObject(found.get(0)); } finally { long finish = System.currentTimeMillis(); TimeLogger.printTimer("RWikiCurrentObjectDaoImpl.getRWikiCurrentObject: " + reference.getName(), start, finish); } }
Example #19
Source File: DynamicFilterTest.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void testManyToManyFilterOnCriteria() { TestData testData = new TestData(); testData.prepare(); Session session = openSession(); session.enableFilter( "effectiveDate" ).setParameter( "asOfDate", new Date() ); Product prod = ( Product ) session.createCriteria( Product.class ) .setResultTransformer( new DistinctRootEntityResultTransformer() ) .add( Expression.eq( "id", testData.prod1Id ) ) .uniqueResult(); assertNotNull( prod ); assertEquals( "Incorrect Product.categories count for filter", 1, prod.getCategories().size() ); session.close(); testData.release(); }
Example #20
Source File: RWikiCurrentObjectDaoImpl.java From sakai with Educational Community License v2.0 | 6 votes |
public RWikiCurrentObject findByGlobalName(final String name) { long start = System.currentTimeMillis(); try { // there is no point in sorting by version, since there is only one // version in // this table. // also using like is much slower than eq HibernateCallback<List> callback = session -> session .createCriteria(RWikiCurrentObject.class) .add(Expression.eq("name", name)) .list(); List found = getHibernateTemplate().execute(callback); if (found.size() == 0) { log.debug("Found {} objects with name {}", found.size(), name); return null; } log.debug("Found {} objects with name {} returning most recent one.", found.size(), name); return (RWikiCurrentObject) proxyObject(found.get(0)); } finally { long finish = System.currentTimeMillis(); TimeLogger.printTimer("RWikiObjectDaoImpl.findByGlobalName: " + name, start, finish); } }
Example #21
Source File: SyllabusManagerImpl.java From sakai with Educational Community License v2.0 | 6 votes |
/** * getSyllabiForSyllabusItem returns the collection of syllabi * @param syllabusItem */ public Set getSyllabiForSyllabusItem(final SyllabusItem syllabusItem) { if (syllabusItem == null) { throw new IllegalArgumentException("Null Argument"); } else { HibernateCallback<Set> hcb = session -> { // get syllabi in an eager fetch mode Criteria crit = session.createCriteria(SyllabusItemImpl.class) .add(Expression.eq(SURROGATE_KEY, syllabusItem.getSurrogateKey())) .setFetchMode(SYLLABI, FetchMode.EAGER); SyllabusItem syllabusItem1 = (SyllabusItem) crit.uniqueResult(); if (syllabusItem1 != null){ return syllabusItem1.getSyllabi(); } return new TreeSet(); }; return getHibernateTemplate().execute(hcb); } }
Example #22
Source File: SbiMetaTableColumnDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
@Override public SbiMetaTableColumn loadTableColumnByName(Session session, String name) throws EMFUserError { logger.debug("IN"); SbiMetaTableColumn toReturn = null; Session tmpSession = session; try { Criterion labelCriterrion = Expression.eq("name", name); Criteria criteria = tmpSession.createCriteria(SbiMetaTableColumn.class); criteria.add(labelCriterrion); toReturn = (SbiMetaTableColumn) criteria.uniqueResult(); if (toReturn == null) return null; } catch (HibernateException he) { logException(he); throw new HibernateException(he); } finally { logger.debug("OUT"); } return toReturn; }
Example #23
Source File: ObjMetadataDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
/** * Load object's metadata by label. * * @param label the label * * @return the metadata * * @throws EMFUserError the EMF user error * * @see it.eng.spagobi.tools.objmetadata.dao.IObjMetadataDAO#loadObjMetadataByLabel(java.lang.String) */ @Override public ObjMetadata loadObjMetadataByLabel(String label) throws EMFUserError { logger.debug("IN"); ObjMetadata toReturn = null; Session tmpSession = null; Transaction tx = null; try { tmpSession = getSession(); tx = tmpSession.beginTransaction(); Criterion labelCriterion = null; labelCriterion = Expression.eq("label", label); Criteria criteria = tmpSession.createCriteria(SbiObjMetadata.class); criteria.add(labelCriterion); SbiObjMetadata hibMeta = (SbiObjMetadata) criteria.uniqueResult(); if (hibMeta == null) return null; toReturn = toObjMetadata(hibMeta); tx.commit(); } catch (HibernateException he) { logger.error("Error while loading the metadata with label " + label, he); if (tx != null) tx.rollback(); throw new EMFUserError(EMFErrorSeverity.ERROR, 100); } finally { if (tmpSession != null) { if (tmpSession.isOpen()) tmpSession.close(); } } logger.debug("OUT"); return toReturn; }
Example #24
Source File: RememberMeDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
public RememberMe getRememberMe(Integer rememberMeId) throws EMFInternalError { logger.debug("IN"); Session aSession = null; Transaction tx = null; RememberMe toReturn = null; try { aSession = getSession(); tx = aSession.beginTransaction(); Criterion userIdCriterion = Expression.eq("id", rememberMeId); Criteria criteria = aSession.createCriteria(SbiRememberMe.class); criteria.add(userIdCriterion); //criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); List list = criteria.list(); Iterator it = list.iterator(); while (it.hasNext()) { SbiRememberMe hibObj = (SbiRememberMe) it.next(); toReturn = toRememberMe(hibObj); } return toReturn; } catch (HibernateException he) { logException(he); if (tx != null) tx.rollback(); throw new EMFInternalError(EMFErrorSeverity.ERROR, "100"); } finally { if (aSession != null) { if (aSession.isOpen()) aSession.close(); } logger.debug("OUT"); } }
Example #25
Source File: StatsUpdateManagerImpl.java From sakai with Educational Community License v2.0 | 5 votes |
public Date getEventDateFromLatestJobRun() throws Exception { Date r = getHibernateTemplate().execute(session -> { Criteria c = session.createCriteria(JobRunImpl.class); c.add(Expression.isNotNull("lastEventDate")); c.setMaxResults(1); c.addOrder(Order.desc("id")); List jobs = c.list(); if(jobs != null && jobs.size() > 0){ JobRun jobRun = (JobRun) jobs.get(0); return jobRun.getLastEventDate(); } return null; }); return r; }
Example #26
Source File: PreferenceDaoImpl.java From sakai with Educational Community License v2.0 | 5 votes |
public List findByUser(final String user, final String context) { long start = System.currentTimeMillis(); try { // there is no point in sorting by version, since there is only one // version in // this table. // also using like is much slower than eq HibernateCallback callback = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { String prefcontext = context + "%"; return session.createCriteria(Preference.class).add( Expression.eq("userid", user)).add( Expression.like("prefcontext", prefcontext)).list(); } }; return (List) getHibernateTemplate().execute(callback); } finally { long finish = System.currentTimeMillis(); TimeLogger.printTimer("PreferenceDaoImpl.findByUser: " + user, start, finish); } }
Example #27
Source File: LowFunctionalityDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
/** * Load low functionality by path. * * @param functionalityPath * the functionality path * @param recoverBIObjects * the recover bi objects * * @return the low functionality * * @throws EMFUserError * the EMF user error * * @see it.eng.spagobi.analiticalmodel.functionalitytree.dao.ILowFunctionalityDAO#loadLowFunctionalityByPath(java.lang.String) */ @Override public LowFunctionality loadLowFunctionalityByPath(String functionalityPath, boolean recoverBIObjects) throws EMFUserError { logger.debug("IN"); LowFunctionality funct = null; funct = getFromCache(functionalityPath); if (funct == null) { Session aSession = null; Transaction tx = null; try { aSession = getSession(); tx = aSession.beginTransaction(); Criterion domainCdCriterrion = Expression.eq("path", functionalityPath); Criteria criteria = aSession.createCriteria(SbiFunctions.class); criteria.add(domainCdCriterrion); SbiFunctions hibFunct = (SbiFunctions) criteria.uniqueResult(); if (hibFunct == null) return null; funct = toLowFunctionality(hibFunct, recoverBIObjects); tx.commit(); } catch (HibernateException he) { logger.error("HibernateException", he); if (tx != null) tx.rollback(); throw new EMFUserError(EMFErrorSeverity.ERROR, 100); } finally { if (aSession != null) { if (aSession.isOpen()) aSession.close(); } } putIntoCache(functionalityPath, funct); } logger.debug("OUT"); return funct; }
Example #28
Source File: SakaiPersonManagerImpl.java From sakai with Educational Community License v2.0 | 5 votes |
/** * @see SakaiPersonManager#findSakaiPerson(String) */ public List findSakaiPerson(final String simpleSearchCriteria) { if (log.isDebugEnabled()) { log.debug("findSakaiPerson(String {})", simpleSearchCriteria); } if (simpleSearchCriteria == null || simpleSearchCriteria.length() < 1) throw new IllegalArgumentException("Illegal simpleSearchCriteria argument passed!"); final String match = PERCENT_SIGN + simpleSearchCriteria + PERCENT_SIGN; final HibernateCallback hcb = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { final Criteria c = session.createCriteria(SakaiPersonImpl.class); c.add(Expression.disjunction().add(Expression.ilike(UID, match)).add(Expression.ilike(GIVENNAME, match)).add( Expression.ilike(SURNAME, match))); c.addOrder(Order.asc(SURNAME)); // c.setCacheable(cacheFindSakaiPersonString); return c.list(); } }; log.debug("return getHibernateTemplate().executeFind(hcb);"); List hb = (List) getHibernateTemplate().execute(hcb); if (photoService.overRidesDefault()) { return getDiskPhotosForList(hb); } else { return hb; } }
Example #29
Source File: RememberMeDAOHibImpl.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
public List<RememberMe> getMyRememberMe(String userId) throws EMFInternalError { logger.debug("IN"); logger.debug("*** RememberMe - userId: "+ userId); Session aSession = null; Transaction tx = null; List toReturn = new ArrayList(); try { aSession = getSession(); tx = aSession.beginTransaction(); Criterion userIdCriterion = Expression.eq("userName", userId); Criteria criteria = aSession.createCriteria(SbiRememberMe.class); criteria.add(userIdCriterion); //criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); List list = criteria.list(); Iterator it = list.iterator(); while (it.hasNext()) { SbiRememberMe hibObj = (SbiRememberMe) it.next(); toReturn.add(toRememberMe(hibObj)); } return toReturn; } catch (HibernateException he) { logException(he); if (tx != null) tx.rollback(); throw new EMFInternalError(EMFErrorSeverity.ERROR, "100"); } finally { if (aSession != null) { if (aSession.isOpen()) aSession.close(); } logger.debug("OUT"); } }
Example #30
Source File: TriggerDaoImpl.java From sakai with Educational Community License v2.0 | 5 votes |
public List findByPage(final String space, final String page) { long start = System.currentTimeMillis(); try { // there is no point in sorting by version, since there is only one // version in // this table. // also using like is much slower than eq HibernateCallback callback = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException { return session.createCriteria(Trigger.class).add( Expression.eq("pagespage", space)).add( Expression.eq("pagename", page)).list(); } }; return (List) getHibernateTemplate().execute(callback); } finally { long finish = System.currentTimeMillis(); TimeLogger.printTimer("PagePresenceDaoImpl.findByPage: " + space + ":" + page, start, finish); } }