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


Java Session.close方法代码示例

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


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

示例1: testupdateIncrementDownload

import org.hibernate.Session; //导入方法依赖的package包/类
@Test
public void testupdateIncrementDownload() {
    short catalog = 1;
    Integer subCatalog = 3;
    String sort = null;
    String order = null;
    int currentPage = 1;
    int pageSize = 10;
    Boolean noVirus = null;
    Boolean noAds = null;
    Boolean official = null;
    List<App> list = appDao.list(catalog, subCatalog, sort, order, currentPage, pageSize, noAds, noVirus, official);
    assertNotNull(list);
    assertTrue(list.size() > 0);
    App a = list.get(0);
    logger.info("Id:{}", a.getId());
    Session session = sessions.openSession();
    int delta = 9;
    int rows = appDao.updateIncrementDownload(session, a.getId(), delta);
    session.flush();
    assertTrue(rows > 0);
    rows = appDao.updateIncrementDownload(session, a.getId(), -delta);
    session.flush();
    session.close();
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:26,代码来源:AppDaoTest.java

示例2: getApps

import org.hibernate.Session; //导入方法依赖的package包/类
@Override
public List<AppHistory4Index> getApps(int currentPage, int pageSize) {
    String hql = "from AppHistory4Index appIdx where appIdx.indexStatus<>1";

    Session session = null;
    try {
        session = this.sessions.openSession();

        Query q = session.createQuery(hql);
        q.setFirstResult(HibernateHelper.firstResult(currentPage, pageSize));
        q.setMaxResults(pageSize);
        return HibernateHelper.list(q);
    } catch (Exception e) {
        logger.error("error:", e);
        return null;
    } finally {
        if (session != null && session.isOpen()) {
            session.clear();
            session.close();
        }
    }
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:23,代码来源:AppHistory4IndexDaoImpl.java

示例3: saveValidatorEvents

import org.hibernate.Session; //导入方法依赖的package包/类
@DataResolver
public void saveValidatorEvents(Collection<ValidatorEvent> events){
	Session session=this.getSessionFactory().openSession();
	try{
		for(ValidatorEvent v:events){
			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: 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

示例5: insertUserPosition

import org.hibernate.Session; //导入方法依赖的package包/类
@Expose
public void insertUserPosition(String username, String ids) {
	Session session = this.getSessionFactory().openSession();
	try{
		session.createQuery(
				"delete " + UserPosition.class.getName()
				+ " u where u.username = :username")
				.setString("username", username).executeUpdate();
		
		if (StringUtils.isNotEmpty(ids)) {
			UserPosition userPosition;
			for (String id : ids.split(",")) {
				userPosition = new UserPosition();
				userPosition.setId(UUID.randomUUID().toString());
				userPosition.setPositionId(id);
				userPosition.setUsername(username);
				session.save(userPosition);
			}
		}
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:25,代码来源:UserMaintain.java

示例6: listar

import org.hibernate.Session; //导入方法依赖的package包/类
public List listar() {
    Session session = DAOHibernateUtil.getSession();
    List listaCliente = null;
    try {
        session.beginTransaction();           
        listaCliente = session.createQuery("From Cliente").list();
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, ex);
    }
    finally{
        session.close();
        return listaCliente;
    }
}
 
开发者ID:iuryamicussi,项目名称:TrabalhoCrisParte2,代码行数:15,代码来源:DAOCliente.java

示例7: resetMarketForIncrement

import org.hibernate.Session; //导入方法依赖的package包/类
@Override
public void resetMarketForIncrement(Date lastReqDate) {
    Session session = sessions.openSession();
    try {
        Market market = getMarket(session);
        market.setIncrementLastReqCurrentPage(0);
        market.setIncrementTotalPages(0);
        market.setIncrementLastTime(lastReqDate);
        marketDao.update(session, market);
        session.flush();
        session.clear();
        logger.debug("Reset market for increment! {}", market.getMarketName());
    } finally {
        session.close();
    }
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:17,代码来源:AbstractBaseMarketService.java

示例8: updateBySql

import org.hibernate.Session; //导入方法依赖的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

示例9: save

import org.hibernate.Session; //导入方法依赖的package包/类
@Override
public void save(QuotePE pe) {
   	Session session = getSession();
	Transaction tx = session.beginTransaction();
	session.persist(pe);
	tx.commit();
	session.close();
}
 
开发者ID:auTasso,项目名称:SandBoxNGSB,代码行数:9,代码来源:QuoteDAOImpl.java

示例10: query

import org.hibernate.Session; //导入方法依赖的package包/类
public Collection<?> query(DetachedCriteria detachedCriteria,int pageIndex,int pageSize,String dataSourceName){
	Session session=this.getSessionFactory(dataSourceName).openSession();
	try{
		return detachedCriteria.getExecutableCriteria(session).setFirstResult((pageIndex-1)*pageSize).setMaxResults(pageSize).list();
	}finally{
		session.flush();
		session.close();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:10,代码来源:HibernateDao.java

示例11: 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

示例12: save

import org.hibernate.Session; //导入方法依赖的package包/类
@Override
public Doctor save(Doctor doctor) {
	Session session = this.sessionFactory.openSession();
	session.save(doctor);
	session.close();
	return doctor;
}
 
开发者ID:PacktPublishing,项目名称:Building-Web-Apps-with-Spring-5-and-Angular,代码行数:8,代码来源:DoctorDAOImpl.java

示例13: testgetAppByPackageName

import org.hibernate.Session; //导入方法依赖的package包/类
@Test
public void testgetAppByPackageName() {
    String[] packagename = null;
    packagename = new String[] { "ab.gobang", "ab.gobanga", "abacus.contentmenu", "Abacus.Menu", "abc.AsianMM" };
    for (String s : packagename) {
        appDao.getAppByPackageName(s);
    }

    Session session = sessions.openSession();
    appDao.getAppByPackageName(session, "com.g6677.android.bsg");
    session.close();
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:13,代码来源:AppDaoTest.java

示例14: clean

import org.hibernate.Session; //导入方法依赖的package包/类
private void clean(){
	Map<String,Session> sessionMap=ContextHolder.getHibernateSessionMap();
	if(sessionMap==null){
		return;
	}
	for(Session session:sessionMap.values()){
		if(session!=null && session.isOpen()){
			session.flush();
			session.close();
			session=null;
		}
	}
	sessionMap.clear();		
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:15,代码来源:JdbcTransactionManager.java

示例15: findProcessInstance

import org.hibernate.Session; //导入方法依赖的package包/类
public ProcessInstance findProcessInstance(long entryId) throws WorkflowStoreException {

       Session session = null;
       Transaction transaction = null;
       ProcessInstance workflowEntry = null;
       
       try {
           session = sessionFactory.openSession();
           transaction = session.beginTransaction();

           workflowEntry = loadEntry(session, entryId);

           transaction.commit();

       } catch (HibernateException hibernateException) {
           throw new WorkflowStoreException(hibernateException);
       } finally {

           if (transaction != null && transaction.isActive())
                transaction.rollback();

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


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