List of usage examples for javax.persistence Query executeUpdate
int executeUpdate();
From source file:es.ucm.fdi.dalgs.learningGoal.repository.LearningGoalRepository.java
public boolean deleteLearningGoalForCompetence(Competence competence) { try {/*from w w w . j ava 2 s . c om*/ Query query = em.createQuery("UPDATE LearningGoal l SET l.isDeleted = true where l.competence=?1"); query.setParameter(1, competence); query.executeUpdate(); } catch (Exception e) { logger.error(e.getMessage()); return false; } return true; }
From source file:org.opentides.dao.impl.UserDaoJpaImpl.java
public void updateLastLogin(String username) { Calendar now = Calendar.getInstance(TimeZone.getTimeZone(DEFAULT_TIME_ZONE)); Date currentDate = DateUtil.getClientCurrentDate(now, now.getTimeZone()); Query update = getEntityManager().createNativeQuery("update USER_PROFILE up, USERS u set LASTLOGIN='" + DateUtil.dateToString(currentDate, "yyyy-MM-dd HH:mm:ss") + "' where u.id=up.id and u.username='" + username + "'"); update.executeUpdate(); }
From source file:co.sip.dmesmobile.bs.ScPersonDao.java
@Override @Transactional/*w w w. j a v a 2s . co m*/ public int initProcessProduction(long idProductionOrder, long idMachine, int idState) { entityManager = Factory.getEntityManagerFactory().createEntityManager(); String queryUpdateOrder1 = "UPDATE dmes.ot_production_order SET id_production_state = " + idState + " WHERE id_production_order = " + idProductionOrder; String queryUpdateOrder2 = "UPDATE dmes.ot_production_order SET start_date_real = CURRENT_TIMESTAMP " + " WHERE id_production_order = " + idProductionOrder + " AND start_date_real IS NULL"; String queryUpdateProcess = "UPDATE dmes.sc_procces_product_order SET id_process_state = " + idState + " WHERE id_process_product_order = " + "(" + " SELECT id_process_product_order FROM dmes.sc_procces_product_order pp, dmes.sc_product_order po " + " WHERE pp.id_product_order = po.id_product_order AND po.id_order = " + idProductionOrder + " " + " ORDER BY pp.id_process_product_order ASC limit 1 " + ")"; int result = 0; int total = 0; try { entityManager.getTransaction().begin(); Query query = entityManager.createNativeQuery(queryUpdateOrder1); result = query.executeUpdate(); total += result; query = entityManager.createNativeQuery(queryUpdateOrder2); result = query.executeUpdate(); total += result; query = entityManager.createNativeQuery(queryUpdateProcess); result = query.executeUpdate(); total += result; entityManager.getTransaction().commit(); } catch (Exception e) { log.error("Error al intentar iniciar el proceso de un producto", e); entityManager.getTransaction().rollback(); throw e; } return result; }
From source file:es.ucm.fdi.dalgs.learningGoal.repository.LearningGoalRepository.java
public boolean deleteLearningGoalsForCompetences(Collection<Competence> competences) { try {//from www . java 2 s.c om Query query = em.createQuery("UPDATE LearningGoal l SET l.isDeleted = true where l.competence IN ?1"); query.setParameter(1, competences); query.executeUpdate(); } catch (Exception e) { logger.error(e.getMessage()); return false; } return true; }
From source file:org.oscarehr.common.dao.Hl7TextInfoDao.java
public void updateReportStatusByLabId(String reportStatus, int labNumber) { Query query = entityManager .createQuery("update " + modelClass.getName() + " x set x.reportStatus=? where x.labNumber=?"); query.setParameter(1, reportStatus); query.setParameter(2, labNumber);// w ww .j a v a 2 s. co m query.executeUpdate(); }
From source file:org.oscarehr.common.dao.Hl7TextInfoDao.java
public void updateResultStatusByLabId(String resultStatus, int labNumber) { Query query = entityManager .createQuery("update " + modelClass.getName() + " x set x.resultStatus=? where x.labNumber=?"); query.setParameter(1, resultStatus); query.setParameter(2, labNumber);//from w w w.j a v a2 s .c o m query.executeUpdate(); }
From source file:com.eu.evaluation.server.dao.AbstractDAO.java
public int remove(String jpql, MapSqlParameterSource params) { long start = System.currentTimeMillis(); Query query = createQuery(jpql, params); int result = query.executeUpdate(); long end = System.currentTimeMillis(); logger.debug("JPQL?" + (end - start) / 1000 / 3600 + "? " + ((end - start) / 1000 / 60) + "" + ((end - start) / 1000 % 60) + ""); return result; }
From source file:es.ucm.fdi.dalgs.subject.repository.SubjectRepository.java
public boolean deleteSubjectsForTopics(Collection<Topic> topics) { try {//from w w w . j ava 2s . c om Query query = em.createQuery("UPDATE Subject s SET s.isDeleted = true where s.topic IN ?1"); query.setParameter(1, topics); query.executeUpdate(); return true; } catch (Exception e) { logger.error(e.getMessage()); return false; } }
From source file:org.dragoneronca.nlp.wol.domain.WolDomainContext.java
private void createIndices(EntityManager entityManager) { entityManager.getTransaction().begin(); Query q1 = entityManager.createNativeQuery( "CREATE UNIQUE INDEX IF NOT EXISTS SENSESET_UNIQUE ON SenseSet (word, " + "language, POS)"); q1.executeUpdate(); Query q2 = entityManager.createNativeQuery( "CREATE UNIQUE INDEX IF NOT EXISTS SENSE_UNIQUE ON Sense (word, language, " + "POS, number)"); q2.executeUpdate();/*from www . j a va2 s . c o m*/ /*Query q3 = entityManager.createNativeQuery( "CREATE UNIQUE INDEX IF NOT EXISTS SENSERELATION_UNIQUE ON SenseRelation (id," + " DTYPE)"); q3.executeUpdate(); Query q4 = entityManager.createNativeQuery( "CREATE INDEX IF NOT EXISTS SENSERELATION_DTYPE ON SenseRelation (DTYPE)"); q4.executeUpdate(); Query q5 = entityManager.createNativeQuery( "CREATE UNIQUE INDEX IF NOT EXISTS SENSESET_SENSERELATION_DERIVEDTERMS_ID ON " + "SenseSet_SenseRelation (SenseSet_id, DerivedTerms_id)"); q5.executeUpdate(); Query q6 = entityManager.createNativeQuery( "CREATE UNIQUE INDEX IF NOT EXISTS SENSESET_SENSERELATION_RELATEDTERMS_ID ON " + "SenseSet_SenseRelation (SenseSet_id, RelatedTerms_id)"); q6.executeUpdate(); Query q7 = entityManager.createNativeQuery( "CREATE UNIQUE INDEX IF NOT EXISTS SENSESET_SENSERELATION_SYNONYMS_ID ON " + "SenseSet_SenseRelation (SenseSet_id, Synonyms_id)"); q7.executeUpdate(); Query q8 = entityManager.createNativeQuery( "CREATE UNIQUE INDEX IF NOT EXISTS SENSESET_SENSERELATION_TRANSLATIONS_ID ON " + "SenseSet_SenseRelation (SenseSet_id, Translations_id)"); q8.executeUpdate();*/ entityManager.getTransaction().commit(); }
From source file:es.ucm.fdi.dalgs.course.repository.CourseRepository.java
public boolean deleteCoursesFromAcademic(AcademicTerm academic) { try {// w ww .ja va 2s . co m Query query = em.createQuery("UPDATE Course c SET c.isDeleted = true where c.academicTerm=?1"); query.setParameter(1, academic); query.executeUpdate(); } catch (Exception e) { logger.error(e.getMessage()); return false; } return true; }