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


Java Session.delete方法代码示例

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


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

示例1: deleteComponentProfileByControlId

import org.hibernate.Session; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void deleteComponentProfileByControlId(String controlId, String name) {
	DetachedCriteria detachedCriteria = DetachedCriteria.forClass(ComponentConfig.class);
	detachedCriteria.add(Restrictions.eq("controlId", controlId));
	detachedCriteria.add(Restrictions.eq("name", name));
	Session session = this.getSessionFactory().openSession();
	try {
		org.hibernate.Criteria criteria = detachedCriteria.getExecutableCriteria(session);
		List<ComponentConfig> list = criteria.list();
		if (list.size() > 0) {
			String hql = "delete " + ComponentConfigMember.class.getName()
					+ " m where m.componentConfig.id = :configId";
			session.createQuery(hql).setString("configId", list.get(0).getId()).executeUpdate();
			session.delete(list.get(0));
		}
	} finally {
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:21,代码来源:HibernateComponentConfigManager.java

示例2: doHandleRequest

import org.hibernate.Session; //导入方法依赖的package包/类
@Override
protected ModelAndView doHandleRequest(HttpServletRequest request,
		HttpServletResponse response) throws Exception {
	String lobId=request.getParameter("lobId");
	String deploymentId=request.getParameter("deploymentId");
	String id=request.getParameter("id");
	DesignerProcess process=new DesignerProcess();
	process.setId(id);
	Session session=hibernateDao.getSessionFactory().openSession();
	try{
		session.delete(process);
		lobStoreService.deleteString(lobId);
		bpmService.deleteDeployment(deploymentId);
	}finally{
		session.flush();
		session.close();
	}
	return null;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:20,代码来源:DeleteProcessController.java

示例3: unassign

import org.hibernate.Session; //导入方法依赖的package包/类
public String unassign(String managerExternalId, Session hibSession) {
    Transaction tx = null;
    try {
        if (hibSession.getTransaction()==null || !hibSession.getTransaction().isActive())
            tx = hibSession.beginTransaction();
        
        ExamAssignment oldAssignment = new ExamAssignment(this);
        
        setAssignedPeriod(null);
        if (getAssignedRooms()==null) setAssignedRooms(new HashSet());
        getAssignedRooms().clear();
        setAssignedPreference(null);
        
        HashSet otherExams = new HashSet();
        
        for (Iterator j=getConflicts().iterator();j.hasNext();) {
            ExamConflict conf = (ExamConflict)j.next();
            for (Iterator i=conf.getExams().iterator();i.hasNext();) {
                Exam x = (Exam)i.next();
                if (!x.equals(this)) {
                    x.getConflicts().remove(conf);
                    otherExams.add(x);
                }
            }
            hibSession.delete(conf);
            j.remove();
        }

        ExamEvent event = getEvent();
        if (event!=null) hibSession.delete(event);
        
        hibSession.update(this);
        for (Iterator i=otherExams.iterator();i.hasNext();)
            hibSession.update((Exam)i.next());
        
        SubjectArea subject = null;
        Department dept = null;
        for (Iterator i=new TreeSet(getOwners()).iterator();i.hasNext();) {
            ExamOwner owner = (ExamOwner)i.next();
            subject = owner.getCourse().getSubjectArea();
            dept = subject.getDepartment();
            break;
        }
        
        ChangeLog.addChange(hibSession,
                TimetableManager.findByExternalId(managerExternalId),
                getSession(),
                this,
                getName()+" ("+
                (oldAssignment.getPeriod()==null?"N/A":oldAssignment.getPeriodAbbreviation()+" "+oldAssignment.getRoomsName(", "))+
                " &rarr; N/A)",
                ChangeLog.Source.EXAM_INFO,
                ChangeLog.Operation.UNASSIGN,
                subject,
                dept);

        if (tx!=null) tx.commit();
        return null;
    } catch (Exception e) {
        if (tx!=null) tx.rollback();
        e.printStackTrace();
        return "Unassignment of "+getName()+" failed, reason: "+e.getMessage();
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:65,代码来源:Exam.java

示例4: delete

import org.hibernate.Session; //导入方法依赖的package包/类
protected void delete(StandardEventNote note, SessionContext context, Session hibSession) {
	if (note == null) return;
	ChangeLog.addChange(hibSession,
			context,
			note,
			note.getLabel(),
			Source.SIMPLE_EDIT, 
			Operation.DELETE,
			null,
			note instanceof StandardEventNoteDepartment ? ((StandardEventNoteDepartment)note).getDepartment() : null);
	hibSession.delete(note);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:StandardEventNotes.java

示例5: saveDefinitions

import org.hibernate.Session; //导入方法依赖的package包/类
@DataResolver
public void saveDefinitions(Collection<ReportDefinition> definitions){
	Session session=this.getSessionFactory().openSession();
	try{
		IFileService fileService=ContextHolder.getBean(IFileService.BEAN_ID);
		for(ReportDefinition definition:definitions){
			EntityState state=EntityUtils.getState(definition);
			if(state.equals(EntityState.NEW)){
				definition.setCreateDate(new Date());
				session.save(definition);
			}
			if(state.equals(EntityState.MODIFIED)){
				session.update(definition);
			}
			if(state.equals(EntityState.DELETED)){
				fileService.deleteUploadDefinition(definition.getReportFile());
				String hql="delete "+ReportParameter.class.getName()+" where reportDefinitionId=:definitionId";
				session.createQuery(hql).setString("definitionId", definition.getId()).executeUpdate();
				hql="delete "+ReportResource.class.getName()+" where reportDefinitionId=:definitionId";
				session.createQuery(hql).setString("definitionId", definition.getId()).executeUpdate();
				session.delete(definition);
			}
			if(definition.getParameters()!=null){
				this.saveParameters(definition.getParameters());
			}
			if(definition.getResources()!=null){
				this.saveResources(definition.getResources());
			}
		}
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:35,代码来源:ReportMaintain.java

示例6: saveGroups

import org.hibernate.Session; //导入方法依赖的package包/类
@DataResolver
public void saveGroups(Collection<Group> groups) throws Exception{
	IUser user=ContextHolder.getLoginUser();
	if(user==null){
		throw new NoneLoginException("Please login first");
	}
	String companyId=user.getCompanyId();
	if(StringUtils.isNotEmpty(getFixedCompanyId())){
		companyId=getFixedCompanyId();
	}
	Session session=this.getSessionFactory().openSession();
	try{
		for(Group g:groups){
			EntityState state=EntityUtils.getState(g);
			if(state.equals(EntityState.NEW)){
				g.setId(UUID.randomUUID().toString());
				g.setCompanyId(companyId);
				g.setCreateDate(new Date());
				session.save(g);
			}else if(state.equals(EntityState.MODIFIED)){
				session.update(g);
			}else if(state.equals(EntityState.DELETED)){
				roleService.deleteRoleMemeber(g.getId(), MemberType.Group);
				groupService.deleteGroupMemeber(g.getId(), MemberType.Group);
				session.delete(g);
			}
		}
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:33,代码来源:GroupMaintain.java

示例7: delete

import org.hibernate.Session; //导入方法依赖的package包/类
protected void delete(InstructorAttributeType type, SessionContext context, Session hibSession) {
	if (type == null) return;
	ChangeLog.addChange(hibSession,
			context,
			type,
			type.getReference(),
			Source.SIMPLE_EDIT, 
			Operation.DELETE,
			null,
			null);
	hibSession.delete(type);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:InstructorAttributeTypes.java

示例8: destroy

import org.hibernate.Session; //导入方法依赖的package包/类
/**
 * Delete a Channel
 * @param id channel ID.
 * @return A response.
 */
@DELETE
@Path("{id}/")
public Response destroy(@PathParam("id") Long id) {
    LOGGER.info("#DELETE " + id);
    Response response = null;
    if (this.authorization) {
        Session session = HibernateUtil.getSessionFactory().openSession();
        try {
            session.beginTransaction();
            Channel channel = session.get(Channel.class, id);

            if (channel == null) {
                response = Error.notFound(String.valueOf(id))
                        .getResponse();
                LOGGER.warning("#DELETE {" + id + "} " + response.toString());
            } else {
                session.delete(channel);
                response = Response
                        .ok(channel)
                        .build();
                LOGGER.info("#DELETE {" + id + "} " + response.toString());
            }
            session.getTransaction().commit();
            session.close();
        } catch (Exception exception) {
            response = Error.internalServer(exception)
                    .getResponse();
            LOGGER.warning("#DELETE {" + id + "} " + exception.getLocalizedMessage());
            session.getTransaction().rollback();
        }
    } else {
        response = this.getUnauthorization();
    }
    return response;
}
 
开发者ID:YMonnier,项目名称:docker-restful-java,代码行数:41,代码来源:ChannelController.java

示例9: delete

import org.hibernate.Session; //导入方法依赖的package包/类
protected void delete(PosMajor major, SessionContext context, Session hibSession) {
	if (major == null) return;
	ChangeLog.addChange(hibSession,
			context,
			major,
			major.getCode() + " " + major.getName(),
			Source.SIMPLE_EDIT, 
			Operation.DELETE,
			null,
			null);
	hibSession.delete(major);		
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:Majors.java

示例10: remove

import org.hibernate.Session; //导入方法依赖的package包/类
public void remove(Long piid) {

        if( piid == null)
            throw new PersistentVarsException("Could not remove properties for 'null' piid");

        Session session = null;
        Transaction transaction = null;

        try  {
            session = this.sessionFactory.openSession();
            transaction = session.beginTransaction();

            Collection<String> keys = getKeys(piid, null, null);

            for(String key : keys)
                session.delete(getItem(session, piid, key));

            transaction.commit();
            
        } catch( HibernateException hibernateException ) {
            throw new PersistentVarsException("Could not remove all keys: " + hibernateException.getMessage());
        } finally {
            // Rollback if 'commit' failed 
            if(transaction != null && transaction.isActive())
                transaction.rollback();

            if (session != null) 
                session.close();
        }
    }
 
开发者ID:will-gilbert,项目名称:OSWf-OSWorkflow-fork,代码行数:31,代码来源:HibernatePersistentVarsDAO.java

示例11: deleteUploadDefinition

import org.hibernate.Session; //导入方法依赖的package包/类
public void deleteUploadDefinition(String id) {
	Session session=this.getSessionFactory().openSession();
	try{
		UploadDefinition definition=(UploadDefinition)session.get(UploadDefinition.class, id);
		if(definition==null){
			throw new RuntimeException("Upload definition ["+id+"] is not exist!");
		}
		if(StringUtils.isEmpty(definition.getUploadProcessorKey())){
			throw new RuntimeException("Upload definition ["+definition.getId()+"] has not set processor!");
		}
		String key=definition.getUploadProcessorKey();
		IFileProcessor targetProcessor=null;
		for(IFileProcessor processor:processors){
			if(processor.key().equals(key)){
				targetProcessor=processor;
				break;
			}
		}
		if(targetProcessor==null){
			throw new RuntimeException("The processor ["+key+"] is not exist!");
		}
		targetProcessor.deleteFile(definition);
		session.delete(definition);
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:29,代码来源:FileServiceImpl.java

示例12: removeProcessInstances

import org.hibernate.Session; //导入方法依赖的package包/类
private void removeProcessInstances(ProcessInstance pi,Session session){
	long pid=pi.getParentId();
	if(pid>0){
		ProcessInstance parent=(ProcessInstance)session.get(ProcessInstance.class, pid);
		parent.setState(ProcessInstanceState.End);
		session.delete(parent);
		removeProcessInstances(parent,session);
	}
}
 
开发者ID:youseries,项目名称:uflo,代码行数:10,代码来源:ExecuteEndNodeCommand.java

示例13: deleteClasses

import org.hibernate.Session; //导入方法依赖的package包/类
private void deleteClasses(InstructionalOfferingModifyForm frm, InstrOfferingConfig ioc, Session hibSession, HashMap tmpClassIdsToRealClasses){
 	if (ioc.getSchedulingSubparts() != null) {
SchedulingSubpart ss = null;
ArrayList lst = new ArrayList();
      ArrayList subpartList = new ArrayList(ioc.getSchedulingSubparts());
      Collections.sort(subpartList, new SchedulingSubpartComparator());

      for(Iterator it = subpartList.iterator(); it.hasNext();){
      	ss = (SchedulingSubpart) it.next();
      	if (ss.getParentSubpart() == null){
      		buildClassList(ss.getClasses(), lst);
      	}
      }

      Class_ c;
      for (int i = (lst.size() - 1); i >= 0; i--){
      	c = (Class_) lst.get(i);
      	if (!frm.getClassIds().contains(c.getUniqueId().toString()) && !tmpClassIdsToRealClasses.containsValue(c)){
		if (c.getParentClass() != null){
			Class_ parent = c.getParentClass();
			parent.getChildClasses().remove(c);
			hibSession.update(parent);
		}
		c.getSchedulingSubpart().getClasses().remove(c);
		if (c.getPreferences() != null)
		    c.getPreferences().removeAll(c.getPreferences());
		
		c.deleteAllDependentObjects(hibSession, false);
		
		hibSession.delete(c);
      	}
      }
 	}
  }
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:35,代码来源:InstructionalOfferingModifyAction.java

示例14: delete

import org.hibernate.Session; //导入方法依赖的package包/类
protected void delete(RoomFeatureType type, SessionContext context, Session hibSession) {
	if (type == null) return;
	ChangeLog.addChange(hibSession,
			context,
			type,
			type.getReference(),
			Source.SIMPLE_EDIT, 
			Operation.DELETE,
			null,
			null);
	hibSession.delete(type);
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:13,代码来源:RoomFeatureTypes.java

示例15: deleteEntity

import org.hibernate.Session; //导入方法依赖的package包/类
public void deleteEntity(Object entity) {
	Session session = hibernateTemplate.getSessionFactory().openSession();
	org.hibernate.Transaction tx = session.beginTransaction();
	session.delete(entity);
	try {
		tx.commit();
	} catch (Exception e) {
		e.printStackTrace();
		tx.rollback();
	}
	session.close();
}
 
开发者ID:lrxzl,项目名称:djpt,代码行数:13,代码来源:DaoImpl.java


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