Java Code Examples for org.hibernate.Session.evict()

The following are Jave code examples for showing how to use evict() of the org.hibernate.Session class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hibernateMaster   File: DaoUtil.java   Source Code and License Vote up 6 votes
/**
 * 如果数据库有obj对象就update否则save
 * @param obj
 * @return
 */
public final static boolean saveOrUpdate(BaseRelationalDatabaseDomain obj){
	Session session = null;
	try {
		session = getSession();
		beginTransaction();
		if (BaseUtil.isObjEmpty(DomainUtil.getDomainId(obj))) {
			return save(obj);
		}else {
			BaseRelationalDatabaseDomain smartGet = smartGet(obj);
			if (smartGet != null) {
				session.evict(smartGet);
				session.update(obj);
			}else {
				session.save(obj);
			}
		}
		return managTransaction(true);
	} catch (Exception e) {
		setException(e);
		return managTransaction(false);
	}finally{
		closeSession();
	}
}