当前位置: 首页>>代码示例>>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;未经允许,请勿转载。