📄 stylerepositoryprocessbean.java
字号:
package cn.myapps.core.style.repository.ejb;
import java.util.Collection;
import org.apache.commons.beanutils.PropertyUtils;
import org.hibernate.StaleObjectStateException;
import cn.myapps.base.dao.DAOFactory;
import cn.myapps.base.dao.IBaseDAO;
import cn.myapps.base.dao.PersistenceUtils;
import cn.myapps.base.dao.ValueObject;
import cn.myapps.base.ejb.BaseProcessBean;
import cn.myapps.core.dynaform.form.action.ImpropriateException;
import cn.myapps.core.style.repository.dao.StyleRepositoryDAO;
public class StyleRepositoryProcessBean extends BaseProcessBean implements
StyleRepositoryProcess {
protected IBaseDAO getDAO() throws Exception {
IBaseDAO dao = DAOFactory.getDefaultDAO(StyleRepositoryVO.class
.getName());
return dao;
}
public StyleRepositoryVO getRepositoryByName(String name, String application)
throws Exception {
return ((StyleRepositoryDAO) getDAO()).getRepositoryByName(name,
application);
}
public Collection getStyleRepositoryByModule(String moduleid,
String application) throws Exception {
return ((StyleRepositoryDAO) getDAO()).getStyleRepositoryByModule(
moduleid, application);
}
public Collection getStyleRepositoryByApplication(String applicationid) throws Exception {
return ((StyleRepositoryDAO) getDAO()).getStyleRepositoryByApplication(
applicationid);
}
public void doUpdate(ValueObject vo) throws Exception {
try {
PersistenceUtils.beginTransaction();
ValueObject po = getDAO().find(vo.getId());
if (((StyleRepositoryVO) vo).getVersion() != ((StyleRepositoryVO) po)
.getVersion())
throw new ImpropriateException("Already having been impropriate by others , can not Save");
((StyleRepositoryVO) vo).setVersion(((StyleRepositoryVO) vo)
.getVersion() + 1);
if (po != null) {
PropertyUtils.copyProperties(po, vo);
getDAO().update(po);
} else {
getDAO().update(vo);
}
PersistenceUtils.commitTransaction();
} catch (ImpropriateException e) {
PersistenceUtils.rollbackTransaction();
throw e;
} catch (Exception e) {
e.printStackTrace();
PersistenceUtils.rollbackTransaction();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -