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