做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

數據字典設計之投影查詢的方法

來源:懂視網 責編:小采 時間:2020-11-27 20:17:30
文檔

數據字典設計之投影查詢的方法

數據字典設計之投影查詢的方法:投影查詢指的是:單擊下拉框,顯示數據庫中數據字典表已有的數據類型名稱,無重復的遍歷到下拉菜單中,如圖所示1.在ElecSystemDDLAction的home添加:public class ElecSystemDDLAction extends BaseAction<ElecSystemDDL&
推薦度:
導讀數據字典設計之投影查詢的方法:投影查詢指的是:單擊下拉框,顯示數據庫中數據字典表已有的數據類型名稱,無重復的遍歷到下拉菜單中,如圖所示1.在ElecSystemDDLAction的home添加:public class ElecSystemDDLAction extends BaseAction<ElecSystemDDL&
  投影查詢指的是:單擊下拉框,顯示數據庫中數據字典表已有的數據類型名稱,無重復的遍歷到下拉菜單中,如圖所示

1.在ElecSystemDDLAction的home添加:

public class ElecSystemDDLAction extends BaseAction<ElecSystemDDL>{
 ElecSystemDDL elecSystemDDL=this.getModel(); 
 //注入數據字典service@Resource(name=IElecSystemDDLService.SERVICE_NAME)
 IElecSystemDDLService elecSystemDDLService; /** 
 * @Name: home
 * @Description: 跳轉到數據字典頁面
 * @Parameters: 無
 * @Return: String:跳轉到system/dictionaryIndex.jsp*/public String home(){// 1:查詢數據庫中已有的數據類型,返回List<ElecSystemDDL>集合
 List<ElecSystemDDL> list=elecSystemDDLService.findSystemDDLListByDistinct();
// 2:將ElecSystemDDL對象放入request中
 request.setAttribute("list", list);return "home";
 }
}

2.在IElecSystemDDLService中聲明投影查詢方法:

public interface IElecSystemDDLService {public static final String SERVICE_NAME="cn.elec.service.impl.ElecSystemDDLServiceImpl";

 List<ElecSystemDDL> findSystemDDLListByDistinct();
 
}

3.在ElecSystemDDLServiceImpl中進行重寫:

public class ElecSystemDDLServiceImpl implements IElecSystemDDLService{//數據字典Dao@Resource(name=IElecSystemDDLDao.SERVICE_NAME)private IElecSystemDDLDao elecSystemDDLDao; 
 /** 
 * @Name: findSystemDDLListByDistinct
 * @Description: 查詢數據庫中已有的數據類型,去掉重復值
 * @Parameters: 無
 * @Return: List:存儲數據類型集合*/@Override
 @Transactional(isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED,readOnly=false)public List<ElecSystemDDL> findSystemDDLListByDistinct() {
 List<ElecSystemDDL> list=elecSystemDDLDao.findSystemDDLListByDistinct();return list;
 }
}

4.在IElecSystemDDLDao中聲明投影查詢方法:

public interface IElecSystemDDLDao extends ICommonDao<ElecSystemDDL> {public static final String SERVICE_NAME="cn.elec.dao.imp.ElecSystemDDLImpl";

 List<ElecSystemDDL> findSystemDDLListByDistinct();
}

5.在ElecSystemDDLImpl中重寫該方法:

@Repository(IElecSystemDDLDao.SERVICE_NAME)public class ElecSystemDDLImpl extends ICommonDaoImpl<ElecSystemDDL> implements IElecSystemDDLDao{/** 
 * @Name: findSystemDDLListByDistinct
 * @Description: 查詢數據庫中已有的數據類型,去掉重復值
 * @Parameters: 無
 * @Return: List:存儲數據類型集合*/@Overridepublic List<ElecSystemDDL> findSystemDDLListByDistinct() {//返回List集合List<ElecSystemDDL> systemList = new ArrayList<ElecSystemDDL>();/**方法一:投影查詢一個字段返回List<Object>中
 String hql="SELECT DISTINCT o.keyword FROM ElecSystemDDL o";
 List<Object> list = this.getHibernateTemplate().find(hql);
 //組織頁面返回結果
 if(list!=null&&list.size()>0){
 for(Object obj:list){
 ElecSystemDDL elecSystemDDL = new ElecSystemDDL();
 //設置數據類型,并添加到systemList
 elecSystemDDL.setKeyword(obj.toString());
 systemList.add(elecSystemDDL);
 }
 }*///方法二:使用hql語句直接將投影查詢的字段放置到對象中String hql="SELECT DISTINCT new cn.elec.domain.ElecSystemDDL(o.keyword) FROM ElecSystemDDL o";
 systemList=this.getHibernateTemplate().find(hql);return systemList;
 }
}

  其中第二種查詢方案需要在ElecSystemDDL中創建一個帶參得的構造方法:

public ElecSystemDDL() {//無參構造方法} 
public ElecSystemDDL(String keyword) {//帶參構造方法this.keyword=keyword;
}  

6.在dictionaryIndex.jsp遍歷:

  因為在Actionl類中將List<ElecSystemDDL>集合放入request對象中,屬性名為list。當dictionary.jsp頁面獲得request.list之后需要將ElecSystemDDL對象的keyword屬性遍歷出來,放入下拉選項框中,有兩種方案:

<tr>
 <td class="ta_01" align="right" width="35%" >類型列表:</td>
 <td class="ta_01" align="left" width="30%" >
 <!-- 方案一 <select name="keyword" class="bg" style="width:180px" onchange="changetype()">
 <option value="jerrynew"></option>
 <s:iterator value="#request.list" var="sys">
 <option value="<s:property value="#sys.keyword"/>">
 <s:property value="#sys.keyword"/>
 </option>
 </s:iterator>
 </select>
 --> 
 
 <!-- 方案二 -->
 <s:select list="#request.list" name="keyword" id="keyword" 
 listKey="keyword" listValue="keyword" 
 headerKey="jerrynew" headerValue="" 
 cssClass="bg" cssStyle="width:180px" onchange="changetype()">
 </s:select>
 
 </td>
</tr>

測試,在數據字典首頁功能頁面中,下拉菜單能正確顯示類型名稱。

1.hql和sql語句的投影查詢:

(1)如果投影查詢是一個字段,此時返回List<Object>,例如

String hql = "SELECT DISTINCT o.keyword FROM ElecSystemDDL o";
List<Object> list = this.getHibernateTemplate().find(hql);

(2)如果投影查詢是多個字段,此時返回List<Object[]>,例如

String hql = "SELECT DISTINCT o.keyword,o.ddlName FROM ElecSystemDDL o";
List<Object[]> list = this.getHibernateTemplate().find(hql);

(3)如果投影查詢是多個字段,此時返回List<Object[]>,例如

String hql = "SELECT o,o.ddlName FROM ElecSystemDDL o";
List<Object[]> list = this.getHibernateTemplate().find(hql);

  數組的第一個值,是一個ElecSystemDDL的對象,數組的第二個值表示字段ddlName的值。

(4)如果投影查詢是一個對象,此時返回List<ElecSystemDDL>,例如

String hql = "SELECT o FROM ElecSystemDDL o";
List<ElecSystemDDL> list = this.getHibernateTemplate().find(hql);

(5)如果是hql語句,使用hql語句直接將投影查詢的字段放置到對象中,例如

String hql = "SELECT DISTINCT new cn.itcast.elec.domain.ElecSystemDDL(o.keyword) FROM ElecSystemDDL o";
List<ElecSystemDDL> list = this.getHibernateTemplate().find(hql);

2.頁面使用select進行遍歷List<ElecSystemDDL>

(1)方案一:使用<s:iterator>遍歷<option>

<select name="keyword" class="bg" style="width:180px" onchange="changetype()">
 <option value="jerrynew"></option>
 <s:iterator value="#request.list" var="system">
 <option value="<s:property value="#system.keyword"/>">
<s:property value="#system.keyword"/>
</option>
 </s:iterator>
</select>

(2)方案二:使用<s:select>

<s:select list="#request.list" name="keyword" id="keyword"listKey="keyword" listValue="keyword"headerKey="jerrynew" headerValue=""cssClass="bg" cssStyle="width:180px" onchange="changetype()">
</s:select>

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

數據字典設計之投影查詢的方法

數據字典設計之投影查詢的方法:投影查詢指的是:單擊下拉框,顯示數據庫中數據字典表已有的數據類型名稱,無重復的遍歷到下拉菜單中,如圖所示1.在ElecSystemDDLAction的home添加:public class ElecSystemDDLAction extends BaseAction<ElecSystemDDL&
推薦度:
標簽: 查詢 方法 設計
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 平顺县| 翼城县| 桑植县| 克拉玛依市| 陆丰市| 勃利县| 泽州县| 赤水市| 苍梧县| 武义县| 孝义市| 海阳市| 延寿县| 佳木斯市| 诸暨市| 望江县| 民丰县| 大名县| 兰坪| 香港| 吐鲁番市| 泉州市| 延安市| 鄂伦春自治旗| 庆元县| 遂平县| 鱼台县| 承德县| 东丰县| 民丰县| 怀安县| 丹巴县| 抚松县| 巫山县| 北京市| 新化县| 西乡县| 扶风县| 响水县| 平遥县| 视频|