📄 dictionarydaoimpl.java
字号:
/**
*
*/
package com.sunwah.baseapp.system.dao;
import java.util.List;
import com.sunwah.baseapp.common.DictionaryConstants;
import com.sunwah.baseapp.dao.GenericDaoImpl;
import com.sunwah.baseapp.system.model.DictionaryData;
import com.sunwah.baseapp.system.model.DictionaryType;
/**
* @author MARK
*
*/
public class DictionaryDaoImpl extends GenericDaoImpl<DictionaryType, Long>
implements DictionaryDao {
private static final String GET_ALL_DICTDATAS_SQL = " select a.dictTypeCode,b.dictDataCode,b.dictDataName "
+ " from DictionaryType a,DictionaryData b "
+ " where a.dictTypeId = b.dictionaryType.dictTypeId "
+ " order by a.dictTypeId, b.ordering asc ";
private static final String GET_AVAILABLE_DICTDATAS_SQL = " select a.dictTypeCode,b.dictDataCode,b.dictDataName "
+ " from DictionaryType a,DictionaryData b "
+ " where a.dictTypeId = b.dictionaryType.dictTypeId "
+ " and a.state='"
+ DictionaryConstants.STATE_ENABLED
+ "' and b.state='"
+ DictionaryConstants.STATE_ENABLED
+ "' order by a.dictTypeId, b.ordering asc ";
public DictionaryDaoImpl() {
super(DictionaryType.class);
}
/*
* (non-Javadoc)
*
* @see com.sunwah.baseapp.system.dao.DictionaryDao#getAllDictDatas()
*/
@Override
public List getAllDictDatas() {
return this.getHibernateTemplate().find(GET_ALL_DICTDATAS_SQL);
}
/*
* (non-Javadoc)
*
* @see com.sunwah.baseapp.system.dao.DictionaryDao#getAvailableDictDatas()
*/
@Override
public List getAvailableDictDatas() {
return this.getHibernateTemplate().find(GET_AVAILABLE_DICTDATAS_SQL);
}
@Override
public DictionaryType findDictTypeByDictTypeCode(String dictTypeCode) {
List<DictionaryType> dictTypes = super.findByProperty("dictTypeCode",
dictTypeCode);
return dictTypes.size() > 0 ? dictTypes.get(0) : null;
}
@Override
public DictionaryType findDictTypeByDictTypeName(String dictTypeName) {
List<DictionaryType> dictTypes = super.findByProperty("dictTypeName",
dictTypeName);
return dictTypes.size() > 0 ? dictTypes.get(0) : null;
}
@Override
public DictionaryData findDictDataByDictDataCode(Long dictTypeId,
String dictDataCode) {
StringBuffer stringBuffer = new StringBuffer(
" from DictionaryData a where a.dictionaryType.dictTypeId = ");
stringBuffer.append(dictTypeId);
stringBuffer.append(" and a.dictDataCode ='");
stringBuffer.append(dictDataCode);
stringBuffer.append("'");
List list = this.getHibernateTemplate().find(stringBuffer.toString());
return list.size() > 0 ? (DictionaryData) list.get(0) : null;
}
@Override
public DictionaryData findDictDataByDictDataName(Long dictTypeId,
String dictDataName) {
StringBuffer stringBuffer = new StringBuffer(
" from DictionaryData a where a.dictionaryType.dictTypeId = ");
stringBuffer.append(dictTypeId);
stringBuffer.append(" and a.dictDataName ='");
stringBuffer.append(dictDataName);
stringBuffer.append("'");
List list = this.getHibernateTemplate().find(stringBuffer.toString());
return list.size() > 0 ? (DictionaryData) list.get(0) : null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -