참고자료 :
http://cafe.naver.com/deve.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=947


 
내가 해결한 방식 :

composite-id 를 이용한경우 해당 변수에 접근하기위해 . 을 이용한다.
예) useSeqType.useSeq

hbm.xml 에 정의된 테이블 정보
<class name="kr.or.copyright.freeuse.domain.donation.DonationUseUser" table="donation_use_user">
  <comment>정보</comment>
  <composite-id name="useSeqType" class="kr.or.copyright.freeuse.domain.donation.DonationUseCsUseSeqAtUserType">
   <key-property name="useSeq" column="use_seq" type="integer" />
   <key-property name="userType" column="user_type" type="integer" />
  </composite-id>
 
  <property name="userName" column="user_name" type="string" />
  <property name="userNationality" column="user_nationality" type="string" />
  <property name="userJumin" column="user_jumin" type="string" />
  <property name="userTel" column="user_tel" type="string" />
  <property name="userEmail" column="user_email" type="string" />
  <property name="userZip" column="user_zip" type="string" />
  <property name="userAddr1" column="user_addr1" type="string" />
  <property name="userAddr2" column="user_addr2" type="string" />
  <property name="createId" column="create_id" type="string" />
  <property name="createDate" column="create_date" type="timestamp" />
 </class>


protected String selectDonationRegManageQuery(String searchType, String key, String keyword, int currentPage, int countPerPage, boolean isTotal){
  String andQuery = "";
 
  StringBuffer sb = new StringBuffer();
  if(searchType.equals("donation")){
   if(key.equals("TITLE")){ // 제목검색
    andQuery = " AND a.donationTitle LIKE '%"+keyword+"%'";
   }else if(key.equals("DONATOR")){ // 검색
    andQuery = " AND c.userName LIKE '%"+keyword+"%'";
   }
   logger.debug("selectDonationRegManageQuery - 1");
   if(isTotal == true)
   {
    sb.append("SELECT COUNT(*)AS CNT ");
    logger.debug("selectDonationRegManageQuery - 2");
   }else{
    logger.debug("selectDonationRegManageQuery - 3");
    sb.append("SELECT a.donationTitle ");
    sb.append(" , b.userName ");
    sb.append(" , (SELECT branchName FROM WritingBranch WHERE branchSeq = a.branchL)AS branchName ");
    sb.append(" , a.createDate ");
    sb.append(" , a.contents ");
   }
   logger.debug("selectDonationRegManageQuery - 4");
   sb.append(" FROM DonationRegWriting a, DonationReg b, CommonCode c ");
   sb.append(" WHERE a.donationWritingSeq = b.donationRegSeq ");
   sb.append(" AND a.donationStatus = c.statusCode ");
   sb.append(" AND c.workCode = '02' ");
   sb.append(" AND c.statusCode = '07' ");
   sb.append(andQuery);
  }else if(searchType.equals("use")){
   if(key.equals("DONATOR")){
    andQuery = " AND d.userName LIKE '%"+keyword+"%'";
   }else if(key.equals("ISSUE_DATE")){
    andQuery = " AND d.createDate LIKE '%"+keyword+"%'";
   }
   if(isTotal == true)
   {
    sb.append("SELECT COUNT(*)AS CNT ");
   }else{
    sb.append("SELECT c.donationWritingSeq ");
    sb.append(" , c.donationTitle ");
    sb.append(" , d.userName ");
    sb.append(" , b.userName ");
    sb.append(" , a.useReason ");
    sb.append(" , e.createDate ");
   }
   sb.append(" FROM DonationUseApp a, DonationUseUser b ");
   sb.append(" , DonationRegWriting c, DonationReg d ");
   sb.append(" , DonationPermission e ");
   sb.append(" WHERE a.userId = e.userId ");
   sb.append(" AND a.useSeq = b.useSeqType.useSeq ");
   sb.append(" AND a.useSeq = e.useSeq ");
   sb.append(" AND a.donationSeq = e.donationNo ");
   sb.append(" AND a.donationSeq = c.donationWritingSeq ");
   sb.append(" AND c.donationWritingSeq = d.donationRegSeq");
   sb.append(andQuery);
  }else if(searchType.equals("donPrint")){
   if(key.equals("DONATOR")){
    andQuery = " AND b.userName LIKE '%"+keyword+"%'";
   }else if(key.equals("ISSUE_DATE")){
    andQuery = " AND c.printDate LIKE '%"+keyword+"%'";
   }
   if(isTotal == true)
   {
    sb.append("SELECT COUNT(*)AS CNT ");
   }else{
    sb.append("SELECT c.printDate ");
    sb.append(" , a.donationTitle ");
    sb.append(" , b.userName ");
    sb.append(" , c.donationCode ");
    sb.append(" , a.createDate ");
    sb.append(" , c.userId ");
   }
   sb.append(" FROM DonationRegWriting a, DonationReg b ");
   sb.append(" , DonationPrint c ");
   sb.append(" WHERE a.userId = c.userId ");
   sb.append(" AND a.donationRegSeq = b.donationRegSeq");
   sb.append(" AND a.donationWritingSeq = c.donationSeq");
   sb.append(andQuery);
  }else if(searchType.equals("usePrint")){
   if(key.equals("USER_NAME")){
    andQuery = " AND d.userName LIKE '%"+keyword+"%'";
   }else if(key.equals("ISSUE_DATE")){
    andQuery = " AND c.printDate LIKE '%"+keyword+"%'";
   }
   if(isTotal == true)
   {
    sb.append("SELECT COUNT(*)AS CNT ");
   }else{
    sb.append("SELECT a.donationWritingSeq ");
    sb.append(" , c.printDate ");
    sb.append(" , a.donationTitle ");
    sb.append(" , d.userName ");
    sb.append(" , e.useReason ");
    sb.append(" , c.donationCode ");
    sb.append(" , f.createDate ");
    sb.append(" , c.userId ");
   }
   sb.append(" FROM DonationRegWriting a, DonationReg b ");
   sb.append(" , DonationPrint c, DonationUseUser d ");
   sb.append(" , DonationUseApp e, DonationPermission f ");
   sb.append(" WHERE a.userId = c.userId ");
   sb.append(" AND a.donationRegSeq = b.donationRegSeq ");
   sb.append(" AND a.donationWritingSeq = c.donationSeq ");
   sb.append(" AND d.useSeqType.useSeq = e.useSeq ");
   sb.append(" AND e.useSeq = f.useSeq ");
   sb.append(" AND a.donationWritingSeq = e.donationSeq ");
   sb.append(" AND a.donationWritingSeq = f.donationNo");
   sb.append(andQuery);
  }
  logger.debug("### selectDonationRegManageQuery : " + sb.toString());
  return sb.toString();
 }
04 28, 2009 00:03 04 28, 2009 00:03

Trackback URL : http://develop.sunshiny.co.kr/trackback/205

Leave a comment

« Previous : 1 : ... 225 : 226 : 227 : 228 : 229 : 230 : 231 : 232 : 233 : ... 381 : Next »

Recent Posts

  1. Oracle - 바인드 변수에 대하여(테스트)
  2. Oracle - 디폴트 롤, DBA, CONNECT,...
  3. Oracle - 권한 및 롤 관리
  4. Oracle - SQL*PLUS의 SYSDBA 접근 제어
  5. Oracle - PFILE, SPFILE 에 관하여

Recent Comments

  1. 네 답글 고맙습니다. 좋은 한주 보... sunshiny 05 14,
  2. 좋은 정보 잘 살펴보고 갑니다. ememoho 05 12,
  3. 네. 고맙습니다^^ 행복한 한해 보... sunshiny 01 16,
  4. sunshiny님. 안녕하세요... 올려 주... yihans 01 16,
  5. 답글 주셔서 고맙습니다^^ 소스 복... sunshiny 01 11,

Recent Trackbacks

  1. 윈도우 cmd 명령어 팁 월풍도원(月風道院) - Delight on th... %M
  2. 파일 압축 Like RadioHead %M
  3. Mysql - mysql 설치후 Character set... 멀고 가까움이 다르기 때문 %M

Calendar

«   05 2012   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Bookmarks

  1. 위키피디아
  2. MysqlKorea
  3. Oracle All Documentation
  4. 엑셈
  5. 오라클 클럽
  6. 네이버개발자센터
  7. API - Java
  8. API - Spring
  9. Java Community
  10. Reference - Spring
  11. 스프링사용자
  12. 자바소스
  13. 자바지기
  14. Ready System
  15. Solaris Freeware
  16. Linux-Site
  17. RedHat Korea
  18. 윈디하나의 솔라나라

Site Stats

TOTAL 245410 HIT
TODAY 116 HIT
YESTERDAY 139 HIT