本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}