當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLQuery.executeUpdate方法代碼示例

本文整理匯總了Java中org.hibernate.SQLQuery.executeUpdate方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLQuery.executeUpdate方法的具體用法?Java SQLQuery.executeUpdate怎麽用?Java SQLQuery.executeUpdate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.SQLQuery的用法示例。


在下文中一共展示了SQLQuery.executeUpdate方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteHoldingExtras

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
protected void deleteHoldingExtras(Session session, long itemId)
{
	SQLQuery sqlQuery = session
		.createSQLQuery(sqlQuery("delete from %h_authors where %h_id in (select id from %h where item_id = ?)"));
	sqlQuery.setLong(0, itemId);
	sqlQuery.executeUpdate();
	sqlQuery = session
		.createSQLQuery(sqlQuery("delete from %h_ids where %h_id in (select id from %h where item_id = ?)"));
	sqlQuery.setLong(0, itemId);
	sqlQuery.executeUpdate();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:12,代碼來源:AbstractCopyrightDao.java

示例2: generateCardId

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
@Override
public String generateCardId(Long cardId) {
	Card card = Card.findCard(cardId);
	if(card.getDesfireIds().get(appName) == null || card.getDesfireIds().get(appName).isEmpty()) {
		Session session = (Session) entityManager.getDelegate();
		SQLQuery existSequenceQuery = session.createSQLQuery("SELECT 1 FROM pg_class where relname = '" + postgresqlSequence + "'");
		if(existSequenceQuery.list().isEmpty()) {
			SQLQuery createSequenceQuery = session.createSQLQuery("CREATE SEQUENCE " + postgresqlSequence);
			int createSequenceQueryResult = createSequenceQuery.executeUpdate();
			log.info("create sequence result : " + createSequenceQueryResult);
		}
		SQLQuery nextValQuery = session.createSQLQuery("SELECT nextval('" + postgresqlSequence + "')");
		BigInteger nextVal = (BigInteger)nextValQuery.list().get(0);
		card.getDesfireIds().put(appName, Long.toString(nextVal.longValue() + getIdCounterBegin(card)));
		card.merge();
	}
	return card.getDesfireIds().get(appName);
}
 
開發者ID:EsupPortail,項目名稱:esup-sgc,代碼行數:19,代碼來源:GenericCardIdService.java

示例3: delete

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
@Override
   public void delete(Object object) {
// remove references to the removed page
WikiPage removedWikiPage = (WikiPage) object;
String title = removedWikiPage.getTitle();
String escapedTitle = WikiPageDTO.javaScriptEscape(title);
String codeToReplace = WikiPageDAO.CHANGE_WIKI_JAVASCRIPT_METHOD.replace("?", escapedTitle);
String replacementCode = "#";

SQLQuery query = getSessionFactory().getCurrentSession().createSQLQuery(REMOVE_WIKI_REFERENCES);
query.setString(0, codeToReplace);
query.setString(1, replacementCode);
query.setLong(2, removedWikiPage.getParentWiki().getUid());

super.delete(object);
query.executeUpdate();
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:WikiPageDAO.java

示例4: updateBySql

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
public void updateBySql(String sql, Object[] vals) {
	Session session = hibernateTemplate.getSessionFactory().openSession();
	
	org.hibernate.Transaction tx = session.beginTransaction();
	
	SQLQuery query = session.createSQLQuery(sql);
	if(vals != null) {
		for(int i=0;i<vals.length;i++) {
			if(vals[i] instanceof Integer) {
				query.setInteger(i, (Integer)vals[i]);
			} else {
				query.setString(i, vals[i].toString());
			}
		}
	}
	query.executeUpdate();
	
	try {
		tx.commit();
	} catch (Exception e) {
		e.printStackTrace();
		tx.rollback();
	}
	session.close(); 
}
 
開發者ID:lrxzl,項目名稱:djpt,代碼行數:26,代碼來源:DaoImpl.java

示例5: executeBySql

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
public int executeBySql(String sql, Map<String, Object> map) {
	SQLQuery query = hibernateTemplate.getSessionFactory()
			.getCurrentSession().createSQLQuery(sql);
	if (map != null) {
		setQuery(map, query);
	}
	return query.executeUpdate();
}
 
開發者ID:liuxuanhai,項目名稱:WeiXing_xmu-2016-MrCode,代碼行數:9,代碼來源:BaseDaoImpl.java

示例6: deletePortionExtras

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
protected void deletePortionExtras(Session session, long itemId)
{
	SQLQuery sqlQuery = session
		.createSQLQuery(sqlQuery("delete from %p_authors where %p_id in (select id from %p where item_id = ?)"));
	sqlQuery.setLong(0, itemId);
	sqlQuery.executeUpdate();
	sqlQuery = session
		.createSQLQuery(sqlQuery("delete from %p_topics where %p_id in (select id from %p where item_id = ?)"));
	sqlQuery.setLong(0, itemId);
	sqlQuery.executeUpdate();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:12,代碼來源:AbstractCopyrightDao.java

示例7: createUsersForSession

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
@Override
   public int createUsersForSession(final PeerreviewSession session) {

SQLQuery query = getSession().createSQLQuery(CREATE_USERS);
query.setLong("session_uid", session.getUid()).setLong("tool_session_id", session.getSessionId());
return query.executeUpdate();
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:8,代碼來源:PeerreviewUserDAOHibernate.java

示例8: executeUpdateBySql

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
@Override
public int executeUpdateBySql(String executeSql, Object... params) {
    Query query = entityManager.createNativeQuery(executeSql);
    SQLQuery nativeQuery = query.unwrap(SQLQuery.class);
    if (params != null) {
        for (int i = 0; i < params.length; i++) {
            nativeQuery.setParameter(i, params[i]);
        }
    }

    return nativeQuery.executeUpdate();
}
 
開發者ID:lupindong,項目名稱:xq_seckill_microservice,代碼行數:13,代碼來源:BasicRepositoryImpl.java

示例9: quOrderByIdAdd1

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
/**
 * 更新orderbyId
 * 屬性 belongId所有題目,隻要大於等於orderById+1
 * @param belongId
 * @param orderById
 */
private void quOrderByIdAdd1(String belongId,Integer orderById){
	if(belongId!=null && !"".equals(belongId)){
		String sql="update t_question set order_by_id=order_by_id+1 where belong_id=? and order_by_id>=?";
		//更新排序號
		SQLQuery query=this.getSession().createSQLQuery(sql);
		query.setString(0, belongId);
		query.setInteger(1, orderById);
		query.executeUpdate();
	}
}
 
開發者ID:wkeyuan,項目名稱:DWSurvey,代碼行數:17,代碼來源:QuestionDaoImpl.java

示例10: quOrderByIdDel1

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
public void quOrderByIdDel1(String belongId,Integer orderById){
	if(belongId!=null && !"".equals(belongId)){
		String sql="update t_question set order_by_id=order_by_id-1 where belong_id=? and order_by_id>=?";
		//更新排序號
		SQLQuery query=this.getSession().createSQLQuery(sql);
		query.setString(0, belongId);
		query.setInteger(1, orderById);
		query.executeUpdate();
	}
}
 
開發者ID:wkeyuan,項目名稱:DWSurvey,代碼行數:11,代碼來源:QuestionDaoImpl.java

示例11: quOrderByIdDel1

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
public void quOrderByIdDel1(String quId,Integer orderById){
	if(quId!=null && !"".equals(quId)){
		String sql="update t_qu_radio set order_by_id=order_by_id-1 where qu_id=? and order_by_id>=?";
		//更新排序號
		SQLQuery query=this.getSession().createSQLQuery(sql);
		query.setString(0, quId);
		query.setInteger(1, orderById);
		query.executeUpdate();
	}
}
 
開發者ID:wkeyuan,項目名稱:DWSurvey,代碼行數:11,代碼來源:QuRadioDaoImpl.java

示例12: updateBySql

import org.hibernate.SQLQuery; //導入方法依賴的package包/類
/**
 * native sql excute
 */
public int updateBySql(String sql, final Object[] values) {
    SQLQuery sqlQuery = getSession().createSQLQuery(sql);
    setParameter(sqlQuery, values);
    return sqlQuery.executeUpdate();
}
 
開發者ID:wu05281,項目名稱:admin-shiro,代碼行數:9,代碼來源:DaoSupport.java


注:本文中的org.hibernate.SQLQuery.executeUpdate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。