List of usage examples for org.hibernate Query setString
@Deprecated @SuppressWarnings("unchecked") default Query<R> setString(String name, String val)
From source file:com.dotosoft.dotoquiz.tools.util.HibernateUtil.java
License:Apache License
public static void saveOrUpdateTopicQuestionData(Object sessionTmp, Object topicTmp, Object questionAnswerTmp) { Session session = (Session) sessionTmp; DataTopics topic = (DataTopics) topicTmp; DataQuestions questionAnswer = (DataQuestions) questionAnswerTmp; Query q = session.createQuery( "From DataTopicsQuestions tq where tq.datQuestions.id = :questionId and tq.datTopics.id = :topicId"); q.setString("questionId", questionAnswer.getId()); q.setString("topicId", topic.getId()); List<DataTopicsQuestions> dataTopicQuestions = q.list(); if (!dataTopicQuestions.isEmpty()) { for (DataTopicsQuestions topicQuestion : dataTopicQuestions) { topicQuestion.setDatQuestions(questionAnswer); topicQuestion.setDatTopics(topic); topicQuestion.setIsDelete(QuizConstant.NO); session.update(topicQuestion); }/*from w ww.ja v a 2s . c om*/ } else { DataTopicsQuestions topicQuestion = new DataTopicsQuestions(); topicQuestion.setId(UUID.randomUUID().toString()); topicQuestion.setDatQuestions(questionAnswer); topicQuestion.setDatTopics(topic); topicQuestion.setIsDelete(QuizConstant.NO); topicQuestion.setCreatedBy(QuizConstant.SYSTEM_USER); topicQuestion.setCreatedDt(new Date()); session.save(topicQuestion); } }
From source file:com.douchebag.server.dao.PathDAO.java
License:Apache License
private boolean isAlreadyExist(String p) throws Exception { HibernateHelper hibernateHelper = new HibernateHelper(); Query query = hibernateHelper.createQuery("from " + Path.class.getName() + " p where p.p = :path"); query.setString("path", p); List pathList = hibernateHelper.list(query); hibernateHelper.close();// w w w. j av a 2 s . c o m return !pathList.isEmpty(); }
From source file:com.duroty.application.files.manager.FilesManager.java
License:Open Source License
/** * DOCUMENT ME!//from ww w . j a v a 2 s.com * * @param hsession DOCUMENT ME! * @param repositoryName DOCUMENT ME! * @param mids DOCUMENT ME! * * @throws FilesException DOCUMENT ME! */ public void deleteLabelsFromFiles(Session hsession, String repositoryName, String[] mids) throws FilesException { if ((mids == null) || (mids.length == 0)) { throw new FilesException("ErrorMessages.messages.selection.null"); } try { Query query = hsession.getNamedQuery("delete-labels-by-mid"); query.setParameterList("mids", mids); query.setString("username", repositoryName); query.executeUpdate(); hsession.flush(); } catch (Exception e) { throw new FilesException(e); } finally { GeneralOperations.closeHibernateSession(hsession); } }
From source file:com.duroty.application.files.manager.FilesManager.java
License:Open Source License
/** * DOCUMENT ME!// w w w . j a va2 s .c o m * * @param hsession DOCUMENT ME! * @param repositoryName DOCUMENT ME! * * @return DOCUMENT ME! * * @throws FilesException DOCUMENT ME! */ public Counters getInfoCounters(Session hsession, String repositoryName) throws FilesException { Counters counters = new Counters(); try { Users user = getUser(hsession, repositoryName); Query query = hsession.getNamedQuery("count-new-messages-by-folder"); query.setString("folder", this.folderInbox); query.setInteger("user", user.getUseIdint()); counters.setInbox(((Integer) query.uniqueResult()).intValue()); query = hsession.getNamedQuery("count-new-messages-by-folder"); query.setString("folder", this.folderSpam); query.setInteger("user", user.getUseIdint()); counters.setSpam(((Integer) query.uniqueResult()).intValue()); query = hsession.getNamedQuery("group-count-new-messages-by-label"); query.setInteger("user", user.getUseIdint()); ScrollableResults scroll = query.scroll(); while (scroll.next()) { Integer idint = (Integer) scroll.get(0); Integer count = (Integer) scroll.get(1); counters.addLabel(idint.intValue(), count.intValue()); } counters.setQuota(getQuotaLayer(hsession, user)); } catch (Exception ex) { return null; } finally { GeneralOperations.closeHibernateSession(hsession); } return counters; }
From source file:com.duroty.application.mail.manager.MailManager.java
License:Open Source License
/** * DOCUMENT ME!//from w w w . j a va 2 s . c o m * * @param hsession DOCUMENT ME! * @param repositoryName DOCUMENT ME! * @param mids DOCUMENT ME! * * @throws MailException DOCUMENT ME! */ public void archiveMessages(Session hsession, String repositoryName, String[] mids) throws MailException { if ((mids == null) || (mids.length == 0)) { throw new MailException("ErrorMessages.messages.selection.null"); } try { Query query = hsession.getNamedQuery("archive-messages-by-mid"); query.setString("hidden", this.folderHidden); query.setParameterList("mids", mids); query.setString("username", repositoryName); query.executeUpdate(); hsession.flush(); } catch (Exception e) { throw new MailException(e); } finally { GeneralOperations.closeHibernateSession(hsession); } }
From source file:com.duroty.application.mail.manager.MailManager.java
License:Open Source License
/** * DOCUMENT ME!//from ww w. j a v a 2 s. c o m * * @param hsession DOCUMENT ME! * @param repositoryName DOCUMENT ME! * @param mids DOCUMENT ME! * * @throws MailException DOCUMENT ME! */ public void deleteLabelsFromMessages(Session hsession, String repositoryName, String[] mids) throws MailException { if ((mids == null) || (mids.length == 0)) { throw new MailException("ErrorMessages.messages.selection.null"); } try { Query query = hsession.getNamedQuery("delete-labels-by-mid"); query.setParameterList("mids", mids); query.setString("username", repositoryName); query.executeUpdate(); hsession.flush(); } catch (Exception e) { throw new MailException(e); } finally { GeneralOperations.closeHibernateSession(hsession); } }
From source file:com.duroty.application.mail.manager.MailManager.java
License:Open Source License
/** * DOCUMENT ME!// w ww . ja v a2s . c o m * * @param hsession DOCUMENT ME! * @param repositoryName DOCUMENT ME! * @param folderName DOCUMENT ME! * * @throws MailException DOCUMENT ME! */ public void deleteMessagesInFolder(Session hsession, String repositoryName, String folderName) throws MailException { try { folderName = parseFolder(folderName); } catch (Exception ex) { return; } String newFolder = this.folderTrash; if ((folderName != null) && (folderName.equals(this.folderTrash) || folderName.equals(this.folderSpam))) { newFolder = FOLDER_DELETE; } try { String[] boxes = null; if (folderName.equals(this.folderHidden)) { boxes = new String[] { this.folderBlog, this.folderChat, this.folderHidden, this.folderInbox, this.folderSent, this.folderDraft }; } else { boxes = new String[] { folderName }; } Query query = hsession.getNamedQuery("delete-messages-by-folder"); query.setString("trash", newFolder); query.setParameterList("box", boxes); query.setString("username", repositoryName); query.executeUpdate(); hsession.flush(); } catch (Exception e) { throw new MailException(e); } finally { GeneralOperations.closeHibernateSession(hsession); } }
From source file:com.duroty.application.mail.manager.MailManager.java
License:Open Source License
/** * DOCUMENT ME!/*from w ww . j av a 2 s . c o m*/ * * @param hsession DOCUMENT ME! * @param repositoryName DOCUMENT ME! * @param label DOCUMENT ME! * * @throws MailException DOCUMENT ME! */ public void deleteMessagesInLabel(Session hsession, String repositoryName, Integer label) throws MailException { try { Query query = hsession.getNamedQuery("delete-messages-by-label"); query.setString("trash", this.folderTrash); query.setInteger("label", label.intValue()); query.setString("username", repositoryName); query.executeUpdate(); hsession.flush(); } catch (Exception e) { throw new MailException(e); } finally { GeneralOperations.closeHibernateSession(hsession); } }
From source file:com.duroty.application.mail.manager.MailManager.java
License:Open Source License
/** * DOCUMENT ME!//from w w w .j a v a 2s . com * * @param hsession DOCUMENT ME! * @param repositoryName DOCUMENT ME! * @param mids DOCUMENT ME! * * @throws MailException DOCUMENT ME! */ public void deleteMessages(Session hsession, String repositoryName, String[] mids, String folderName) throws MailException { if ((mids == null) || (mids.length == 0)) { throw new MailException("ErrorMessages.messages.selection.null"); } try { folderName = parseFolder(folderName); } catch (Exception ex) { } String newFolder = this.folderTrash; if ((folderName != null) && (folderName.equals(this.folderTrash) || folderName.equals(this.folderSpam))) { newFolder = FOLDER_DELETE; } try { Query query = hsession.getNamedQuery("delete-messages-by-mid"); query.setString("trash", newFolder); query.setParameterList("mids", mids); query.setString("username", repositoryName); query.executeUpdate(); hsession.flush(); } catch (Exception e) { throw new MailException(e); } finally { GeneralOperations.closeHibernateSession(hsession); } }
From source file:com.duroty.application.mail.manager.MailManager.java
License:Open Source License
/** * DOCUMENT ME!/*w ww. ja v a 2 s. c om*/ * * @param hsession DOCUMENT ME! * @param repositoryName DOCUMENT ME! * @param mids DOCUMENT ME! * @param flag DOCUMENT ME! * * @throws MailException DOCUMENT ME! */ public void flagMessages(Session hsession, String repositoryName, String[] mids, String flag) throws MailException { if ((mids == null) || (mids.length == 0)) { throw new MailException("ErrorMessages.messages.selection.null"); } try { Query query = null; if (flag.equals("RECENT")) { query = hsession.getNamedQuery("recent-messages-by-mid"); } else if (flag.equals("FLAGGED")) { query = hsession.getNamedQuery("flagged-messages-by-mid"); } query.setParameterList("mids", mids); query.setString("username", repositoryName); query.executeUpdate(); hsession.flush(); } catch (Exception e) { throw new MailException(e); } finally { GeneralOperations.closeHibernateSession(hsession); } }