当前位置: 首页>>代码示例>>Java>>正文


Java Session.update方法代码示例

本文整理汇总了Java中org.hibernate.Session.update方法的典型用法代码示例。如果您正苦于以下问题:Java Session.update方法的具体用法?Java Session.update怎么用?Java Session.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.Session的用法示例。


在下文中一共展示了Session.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateTask

import org.hibernate.Session; //导入方法依赖的package包/类
/**
 * 更新task对象
 */
@Override
public boolean updateTask(Task task) {
	Session session = HibernateUtils.getSession();
	 Transaction tx = session.beginTransaction();
	 try {
		session.update(task);
		tx.commit();
		return true;
	} catch (Exception e) {
		 e.printStackTrace();
		 tx.rollback();
		 return false;
	}finally {
		HibernateUtils.closeSession();
	} 
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:20,代码来源:TaskService.java

示例2: updateOauth

import org.hibernate.Session; //导入方法依赖的package包/类
@Override
 /**
  * 更新token对象
  * @param oauth
  * @return
  */
public boolean updateOauth(Oauth oauth) {
	 Session session = HibernateUtils.getSession();
	 Transaction tx = session.beginTransaction();
	 
	 try { 
		session.update(oauth); //调用session的update方法更新oauth对象
		tx.commit(); 
		return true;
	} catch (Exception e) {
		 e.printStackTrace();
		 tx.rollback(); 
		 return false;
	}finally {
		HibernateUtils.closeSession();
	}  
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:23,代码来源:OauthService.java

示例3: saveValidators

import org.hibernate.Session; //导入方法依赖的package包/类
@DataResolver
public void saveValidators(Collection<ValidatorDef> validators){
	Session session=this.getSessionFactory().openSession();
	try{
		for(ValidatorDef v:validators){
			EntityState state=EntityUtils.getState(v);
			if(state.equals(EntityState.NEW)){
				v.setId(UUID.randomUUID().toString());
				session.save(v);
			}
			if(state.equals(EntityState.DELETED)){
				session.delete(v);
			}
			if(state.equals(EntityState.MODIFIED)){
				session.update(v);
			}
		}			
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:ValidatorMaintain.java

示例4: saveJobParameters

import org.hibernate.Session; //导入方法依赖的package包/类
@DataResolver
public void saveJobParameters(Collection<JobParameter> parameters){
	Session session=this.getSessionFactory().openSession();
	try{
		for(JobParameter p:parameters){
			EntityState state=EntityUtils.getState(p);
			if(state.equals(EntityState.NEW)){
				p.setId(UUID.randomUUID().toString());
				session.save(p);
			}
			if(state.equals(EntityState.MODIFIED)){
				session.update(p);
			}
			if(state.equals(EntityState.DELETED)){
				session.delete(p);
			}
		}
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:JobMaintain.java

示例5: updateImage

import org.hibernate.Session; //导入方法依赖的package包/类
/**
 * 更新image对象
 */
@Override
public boolean updateImage(Image image) {
	 
	Session session = HibernateUtils.getSession();
	 Transaction tx = session.beginTransaction();
	 try {
		session.update(image);
		tx.commit();
		return true;
	} catch (Exception e) {
		 e.printStackTrace();
		 tx.rollback();
		 return false;
	}finally {
		HibernateUtils.closeSession();
	}  
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:21,代码来源:ImageService.java

示例6: execute

import org.hibernate.Session; //导入方法依赖的package包/类
public HistoryProcessInstance execute(Context context) {
	Session session=context.getSession();
	HistoryProcessInstance hisProcessInstance=null;
	if(processInstance.getState().equals(ProcessInstanceState.Start)){
		hisProcessInstance=new HistoryProcessInstance();
		hisProcessInstance.setId(processInstance.getHistoryProcessInstanceId());
		hisProcessInstance.setCreateDate(processInstance.getCreateDate());
		hisProcessInstance.setProcessId(processInstance.getProcessId());
		hisProcessInstance.setProcessInstanceId(processInstance.getId());
		hisProcessInstance.setTag(processInstance.getTag());
		hisProcessInstance.setBusinessId(processInstance.getBusinessId());
		hisProcessInstance.setPromoter(processInstance.getPromoter());
		hisProcessInstance.setSubject(processInstance.getSubject());
		session.save(hisProcessInstance);
	}
	if(processInstance.getState().equals(ProcessInstanceState.End)){
		hisProcessInstance=(HistoryProcessInstance)session.createCriteria(HistoryProcessInstance.class).add(Restrictions.eq("processInstanceId",processInstance.getId())).uniqueResult();
		hisProcessInstance.setEndDate(new Date());
		session.update(hisProcessInstance);
	}
	return hisProcessInstance;
}
 
开发者ID:youseries,项目名称:uflo,代码行数:23,代码来源:SaveHistoryProcessInstanceCommand.java

示例7: update

import org.hibernate.Session; //导入方法依赖的package包/类
/**
 * 更新用户信息
 */
@Override
public boolean update(User user) {
	 Session session = HibernateUtils.getSession();
	 Transaction tx = session.beginTransaction();
	 try {
		session.update(user);
		tx.commit();
		return true;
	} catch (Exception e) {
		 e.printStackTrace();
		 tx.rollback();
		 return false;
	}finally {
		HibernateUtils.closeSession();
	} 
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:20,代码来源:UserService.java

示例8: cancelTasks

import org.hibernate.Session; //导入方法依赖的package包/类
private void cancelTasks(Context context, ProcessInstance processInstance, Collection<Task> tasks) {
	Session session=context.getSession();
	SchedulerService schedulerService=(SchedulerService)context.getApplicationContext().getBean(SchedulerService.BEAN_ID);
	Collection<CancelTaskInterceptor> interceptors=context.getApplicationContext().getBeansOfType(CancelTaskInterceptor.class).values();
	for(Task task:tasks){
		for(CancelTaskInterceptor interceptor:interceptors){
			interceptor.intercept(context, task);
		}
		if(dueDefinition!=null){
			schedulerService.removeReminderJob(task);		
		}
		task.setState(TaskState.Canceled);
		session.update(task);
		context.getCommandService().executeCommand(new SaveHistoryTaskCommand(task,processInstance));
	}
}
 
开发者ID:youseries,项目名称:uflo,代码行数:17,代码来源:TaskNode.java

示例9: saveValidatorProperties

import org.hibernate.Session; //导入方法依赖的package包/类
@DataResolver
public void saveValidatorProperties(Collection<ValidatorProperty> properties){
	Session session=this.getSessionFactory().openSession();
	try{
		for(ValidatorProperty v:properties){
			EntityState state=EntityUtils.getState(v);
			if(state.equals(EntityState.NEW)){
				v.setId(UUID.randomUUID().toString());
				session.save(v);
			}
			if(state.equals(EntityState.DELETED)){
				session.delete(v);
			}
			if(state.equals(EntityState.MODIFIED)){
				session.update(v);
			}
		}			
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:23,代码来源:ValidatorMaintain.java

示例10: saveJobs

import org.hibernate.Session; //导入方法依赖的package包/类
@DataResolver
public void saveJobs(Collection<JobDefinition> jobs) throws Exception{
	Session session=this.getSessionFactory().openSession();
	try{
		for(JobDefinition job:jobs){
			EntityState state=EntityUtils.getState(job);
			if(state.equals(EntityState.NEW)){
				job.setId(UUID.randomUUID().toString());
				job.setState(JobState.ready);
				job.setCompanyId(dataService.getCompanyId());
				session.save(job);
			}
			if(state.equals(EntityState.MODIFIED)){
				session.update(job);
			}
			if(state.equals(EntityState.DELETED)){
				String hql="delete "+JobHistory.class.getName()+" where jobId=:jobId";
				session.createQuery(hql).setString("jobId",job.getId()).executeUpdate();
				hql="delete "+JobCalendarRelation.class.getName()+" where jobId=:jobId";
				session.createQuery(hql).setString("jobId", job.getId()).executeUpdate();
				hql="delete "+JobParameter.class.getName()+" where jobId=:jobId";
				session.createQuery(hql).setString("jobId", job.getId()).executeUpdate();
				session.delete(job);
			}
		}
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:31,代码来源:JobMaintain.java

示例11: changeGranted

import org.hibernate.Session; //导入方法依赖的package包/类
@Expose
public void changeGranted(Collection<Map<String,Object>> members) throws Exception{
	Session session=this.getSessionFactory().openSession();
	try{
		for(Map<String,Object> map:members){
			RoleMember rm=(RoleMember)session.load(RoleMember.class,(String)map.get("memberId"));
			rm.setGranted((Boolean)map.get("granted"));
			session.update(rm);
		}			
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:15,代码来源:RoleMemberMaintain.java

示例12: saveMessageTemplates

import org.hibernate.Session; //导入方法依赖的package包/类
@DataResolver
public void saveMessageTemplates(Collection<MessageTemplate> templates){
	IUser user=ContextHolder.getLoginUser();
	if(user==null){
		throw new RuntimeException("Please login first!");
	}
	String companyId=user.getCompanyId();
	if(StringUtils.isNotEmpty(getFixedCompanyId())){
		companyId=getFixedCompanyId();
	}
	Session session=this.getSessionFactory().openSession();
	try{
		for(MessageTemplate t:templates){
			EntityState state=EntityUtils.getState(t);
			if(state.equals(EntityState.NEW)){
				t.setId(UUID.randomUUID().toString());
				t.setCompanyId(companyId);
				session.save(t);
			}
			if(state.equals(EntityState.MODIFIED)){
				session.update(t);
			}
			if(state.equals(EntityState.DELETED)){
				session.delete(t);
			}
		}
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:32,代码来源:MessageTemplateMaintain.java

示例13: saveTaskReminder

import org.hibernate.Session; //导入方法依赖的package包/类
private void saveTaskReminder(TaskReminder reminder, Session session,
		String taskName, String processDefinitionId) {
	String hql;
	String taskReminderId=reminder.getId();
	if(StringUtils.isEmpty(reminder.getId())){
		taskReminderId=UUID.randomUUID().toString();
		reminder.setId(taskReminderId);
		reminder.setTaskName(taskName);
		reminder.setProcessDefinitionId(processDefinitionId);
		String companyId=Configure.getString("bdf2.jbpm4.fixedCompanyId");
		if(StringUtils.isEmpty(companyId)){
			companyId=this.getFixedCompanyId();
		}
		reminder.setCompanyId(companyId);
		session.save(reminder);
	}else{
		session.update(reminder);
	}
	Collection<JobCalendar> calendars=reminder.getCalendars();
	if(calendars!=null){
		hql="delete "+ReminderCalendar.class.getName()+" where taskReminderId=:taskReminderId";
		session.createQuery(hql).setString("taskReminderId",taskReminderId).executeUpdate();
		for(JobCalendar calendar:calendars){
			ReminderCalendar rc=new ReminderCalendar();
			rc.setId(UUID.randomUUID().toString());
			rc.setJobCalendarId(calendar.getId());
			rc.setTaskReminderId(taskReminderId);
			session.save(rc);
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:32,代码来源:NodeConfig.java

示例14: runJob

import org.hibernate.Session; //导入方法依赖的package包/类
@Expose
public void runJob(String jobDefinitionId){
	Session session=this.getSessionFactory().openSession();
	try{
		JobDefinition job=(JobDefinition)session.get(JobDefinition.class, jobDefinitionId);
		job.setState(JobState.running);				
		session.update(job);
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:13,代码来源:JobMaintain.java

示例15: update

import org.hibernate.Session; //导入方法依赖的package包/类
@Override
public void update(Item po) {
	Session session = sessionFactory.getCurrentSession();
	try {
		session.beginTransaction();
		session.update(po);
		session.getTransaction().commit();
	} catch (RuntimeException e) {
		session.getTransaction().rollback();
	}
}
 
开发者ID:lf23617358,项目名称:training-sample,代码行数:12,代码来源:HibernateItemDao.java


注:本文中的org.hibernate.Session.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。