spring로 검색한 결과 :: 시소커뮤니티[SSISO Community]
 
SSISO 카페 SSISO Source SSISO 구직 SSISO 쇼핑몰 SSISO 맛집
추천검색어 : JUnit   Log4j   ajax   spring   struts   struts-config.xml   Synchronized   책정보   Ajax 마스터하기   우측부분

회원가입 I 비밀번호 찾기


SSISO Community검색
SSISO Community메뉴
[카페목록보기]
[블로그등록하기]  
[블로그리스트]  
SSISO Community카페
블로그 카테고리
정치 경제
문화 칼럼
비디오게임 스포츠
핫이슈 TV
포토 온라인게임
PC게임 에뮬게임
라이프 사람들
유머 만화애니
방송 1
1 1
1 1
1 1
1 1
1

spring로 검색한 결과
등록일:2008-06-11 11:57:38
작성자:
제목:JdbcTemplate.queryForInt(String arg0, Object arg1)


spring 가지고 놀다보니... JdbcDaoSupport 가 눈에 띤다..

자세한 내용은 spring doc 를 참고하면 되고...   오늘 신경 거슬리게 만든것 하나..

 

Select Count(*) from tbl_xxx  <-- 이 쿼리 날려야 하는데..

도큐먼트에 SqlFunction 이라는 넘을 쓰면 된단다..

해보니... 잘 된다 ^^

 

그런데!!!!!!

 

Select Count(*) from tbl_xxx where xx > ? and yy < ?                 

이넘~!~! 안된다 ㅜㅜ

 

왜 안되지??

파람 넘겨주는 데가 없다.. 아무래도 PreparedStatement 를 생성하는것 같지 않다.

그래서리... API 찾아보니.. 허거걱...

queryForInt(String arg0, Object arg1)  <-- 요런넘이 있네 ^^

 

Object[] params = new Object[]{new Integer(xx), new Integer(yy)};

return getJdbcTemplate().queryForInt(query, params);

 

간단하게 끝남...

그냥 JDBC 코딩 하는것 보다.. 무지 편리함..

Transaction 처리도.. 설정에서 끝남...

    <!--  Transaction Manager -->
 <bean id="transactionManager"
     class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
     <property name="dataSource"><ref bean="dataSource"/></property>
 </bean>

 

   <bean id="xxxService"
     class = "org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager"><ref local="transactionManager" /></property>
    <property name="target"><ref local="xxxServiceTarget" /></property>
    <property name="transactionAttributes">
       <props>
       <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
    <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
    <prop key="create*">PROPAGATION_REQUIRED,-xxxException</prop>
    <prop key="read*">PROPAGATION_REQUIRED,readOnly</prop>
    <prop key="update*">PROPAGATION_REQUIRED</prop> 
    <prop key="delete*">PROPAGATION_REQUIRED</prop>
       </props>
    </property>
   </bean> 

 

이런식으로... 트랜잭션 매니저 셋팅하고... 프락시 셋팅하고..

설정에서... - 표시로 익셉션을 발생시키면.. 된다..

 

근데.. DataSource 를 반드시 이용해야 하는데..

테스트 할때 proxool 을 사용했다...

데이터 소스 없다 ㅡㅡ

소스포지 가서 proxool cvs 보니... dev 에 테스트 있네 ㅡㅡ

소스 받아서 컴팔하고 해서 성공..