1 / 54

Ibatis (2 nd ) 작성자 : 박찬연 (cypark@ecofrontier.co.kr)

Ibatis (2 nd ) 작성자 : 박찬연 (cypark@ecofrontier.co.kr). 2008 . 04 . 29, EcoFrontier Sangam -dong, Mapo-gu , Seoul. 목차. 소개 datasource sqlMap 트렌젝션 배 치 SqlMapClient 로깅 SimpleDataSource ScriptRunner. 소개.

tommy
Download Presentation

Ibatis (2 nd ) 작성자 : 박찬연 (cypark@ecofrontier.co.kr)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ibatis(2nd)작성자 : 박찬연(cypark@ecofrontier.co.kr) 2008 . 04 . 29, EcoFrontier Sangam-dong, Mapo-gu, Seoul

  2. 목차 • 소개 • datasource • sqlMap • 트렌젝션 • 배치 • SqlMapClient • 로깅 • SimpleDataSource • ScriptRunner

  3. 소개 SQL Maps 프레임워크는 관계형 데이터베이스에 접근할 때 필요한 자바코드를 현저하게 줄일 수 있도록 도와줍니다. SQL Maps는 간단한 XML서술자를 사용해서 간단하게 자바빈즈를SQL statement에 맵핑시킵니다. 간단함이란 다른 프레임워크와 객체관계맵핑툴에 비해 SQL Maps의 가장 큰 장점입니다. SQL Maps를 사용하기 위해서 여러분은 자바빈즈와XML 그리고 SQL에 친숙할 필요가 있습니다. 여러분은 배워야 할것도 거의 없고 테이블을 조인하거나 복잡한 쿼리문을 수행하기 위해 필요한 복잡한 스키마도 없습니다. SQL Maps를 사용하면 당신은 실제 SQL문의 모든 기능을 가질수 있습니다.

  4. 소개 - 다운로드 http://ibatis.apache.org/

  5. datasource <dataSource> 요소 database에 연결하기 위해 datasource를 설정합니다. 프레임워크에서 제공되는 3가지 데이터소스타입이 있지만 여러분만의 데이터소스를 사용할수도 있습니다. SimpleDataSourceFactory SimpleDataSource는 데이터소스를 제공하는 컨테이너가 없는 경우에 connection을 제공하기 위해 기본적으로 풀링(pooling) 데이터소스 구현을 제공합니다. 이것은 iBATISSimpleDataSource connection풀링을 기초로 합니다. sql-map-config.xml코드 참조

  6. datasource DbcpDataSourceFactory 이 구현물은DataSource API를 통해 connection풀링서비스를 제공하기 위해 Jakarta DBCP (Database Connection Pool)을 사용합니다. 이 DataSource는 애플리케이션/웹 컨테이너가 DataSource구현물을 제공하지 못하거나 직접 standalone애플리케이션을 구동할 때 이상적입니다. sql-map-config-dbcp.xml코드 참조

  7. datasource • JndiDataSourceFactory • 이 구현물은 애플리케이션 컨테이너내JNDI컨텍스트로부터DataSource구현물을 가져와야 할것입니다. 이것은 전형적으로 애플리케이션서버를 사용중이고 컨테이너관리 connection풀 그리고 제공되는 DataSource구현물이 있을 때 사용합니다. JDBC DataSource구현물에 접근하기 위한 표준적인 방법은 JNDI컨텍스트를통하는것입니다. • JndiDataSourceFactory는 JNDI를 통해 DataSource에 접근하는 기능을 제공합니다. • <transactionManager type="JDBC" > • <dataSource type="JNDI"> • <property name="DataSource" • value="java:comp/env/jdbc/jpetstore"/> • </dataSource> • </transactionManager>

  8. datasource • 전역(global)트랜잭션을 설정 • <transactionManager type="JTA" > • <property name="UserTransaction" value="java:/ctx/con/UserTransaction"/> • <dataSource type="JNDI"> • <property name="DataSource" • value="java:comp/env/jdbc/jpetstore"/> • </dataSource> • </transactionManager>

  9. sqlMap <sqlMap> 요소 <!--CLASSPATH RESOURCES --> <sqlMap resource="com/ibatis/examples/sql/Customer.xml" /> <sqlMap resource="com/ibatis/examples/sql/Account.xml" /> <sqlMap resource="com/ibatis/examples/sql/Product.xml" /> <!--URL RESOURCES --> <sqlMapurl="file:///c:/config/Customer.xml " /> <sqlMapurl="file:///c:/config/Account.xml " /> <sqlMapurl="file:///c:/config/Product.xml" />

  10. sqlMap statement

  11. sqlMap • 쿼리의 <와> 문제 해결법 • <statement id="getPersonsByAge" parameterClass=”int” resultClass="examples.domain.Person"> • <![CDATA[ • SELECT * • FROM PERSON • WHERE AGE > #value# • ]]> • </statement>

  12. sqlMap • 저장 프로시저 • 파라미터 객체(map)내에서 두개의칼럼사이에두개의이메일주소를 교체하는 예제 • 저장 프로시저는 <procedure> statement요소를 통해 지원됩니다. • <parameterMap id="swapParameters" class="map" > • <parameter property="email1" jdbcType="VARCHAR" javaType="java.lang.String" mode="INOUT"/> • <parameter property="email2" jdbcType="VARCHAR" javaType="java.lang.String" • mode="INOUT"/> • </parameterMap> • <procedure id="swapEmailAddresses" parameterMap="swapParameters" > • {call swap_email_address (?, ?)} • </procedure>

  13. sqlMap • parameterClass • <statement id=”statementName” parameterClass=” examples.domain.Product”> • insert into PRODUCT values (#id#, #description#, #price#) • </statement>

  14. sqlMap • parameterMap • <parameterMap id=”insert-product-param” class=”com.domain.Product”> • <parameter property=”id”/> • <parameter property=”description”/> • </parameterMap> • <statement id=”insertProduct” parameterMap=”insert-product-param”> • insert into PRODUCT (PRD_ID, PRD_DESCRIPTION) values (?,?); • </statement> • 좀더 세부적인 설정이 필요하다면 다음과 같이 합니다. • <parameterMap id=”insert-product-param” class=”com.domain.Product”> • <parameter property=”id” jdbcType=”NUMERIC” javaType=”int” nullValue=”-9999999”/> • <parameter property=”description” jdbcType=”VARCHAR” nullValue=”NO_ENTRY”/> • </parameterMap>

  15. sqlMap • parameterMap(inline) • <statement id=”insertProduct” parameterClass=”com.domain.Product”> • insert into PRODUCT (PRD_ID, PRD_DESCRIPTION) values (#id#, #description#); • </statement> • 타입을 선언하는 것은 다음의 문법을 사용함으로써 인라인파라미터로 할 수 있습니다. • <statement id=”insertProduct” parameterClass=”com.domain.Product”> • insert into PRODUCT (PRD_ID, PRD_DESCRIPTION) values (#id:NUMERIC#, #description:VARCHAR#); • </statement> • 타입을 선언하는 것과 null값 대체는 다음 문법을 사용함으로써 인라인파라미터로 할 수 있습니다. • <statement id=”insertProduct” parameterClass=”com.domain.Product”> • insert into PRODUCT (PRD_ID, PRD_DESCRIPTION) values (#id:NUMERIC:-999999#, #description:VARCHAR:NO_ENTRY#); • </statement>

  16. sqlMap • resultClass • <statement id="getPerson" parameterClass=”int” resultClass="examples.domain.Person"> • SELECT • PER_ID as id, • PER_FIRST_NAME as firstName, • PER_LAST_NAME as lastName, • PER_BIRTH_DATE as birthDate, • PER_WEIGHT_KG as weightInKilograms, • PER_HEIGHT_M as heightInMeters • FROM PERSON • WHERE PER_ID = #value# • </statement>

  17. sqlMap • cacheModel • 24시간마다 또는 관련된 update문이 수행될때마다 지워집니다.(flush) • LRU캐쉬는 객체가 자동으로 캐시로부터 어떻게 삭제되는지 결정하기 위해 Least Recently Used(가장최근에 사용된) 알고리즘을 사용합니다. 캐쉬가 가득 찼을 때 가장 최근에 접근된 객체는 캐쉬로부터삭제됩니다. • FIFO= First In First Out(먼저 들어온 것을 먼저 보낸다.) • OSCACHE = http://www.opensymphony.com/oscache/ • <cacheModel id="product-cache" imlementation="LRU"> • <flushInterval hours="24"/> • <flushOnExecute statement="insertProduct"/> • <flushOnExecute statement="updateProduct"/> • <flushOnExecute statement="deleteProduct"/> • <property name=”size” value=”1000” /> • </cacheModel> • <statement id=”getProductList” parameterClass=”int” cacheModel=”product-cache”> • select * from PRODUCT where PRD_CAT_ID = #value# • </statement>

  18. sqlMap 캐쉬타입들 <cacheModel id="product-cache" type="MEMORY"> <flushInterval hours="24"/> <flushOnExecute statement="insertProduct"/> <flushOnExecute statement="updateProduct"/> <flushOnExecute statement="deleteProduct"/> <property name=”reference-type” value=”WEAK” /> </cacheModel> WEAK (default) 이 참조타입은 대부분의 경우에 가장 좋은 선택이고 참조타입을 정의하지 않는다면 디폴트로 설정되는 값입니다. 이것은 대개의 결과에 성능을 향상시킬것입니다. 하지만 할당된 다른 객체내에서 사용되는 메모리를 완전히 제거할것입니다. 그 결과는 현재 사용중이지 않다는 것을 가정합니다.

  19. sqlMap 캐쉬타입들 <cacheModel id="product-cache" type="MEMORY"> <flushInterval hours="24"/> <flushOnExecute statement="insertProduct"/> <flushOnExecute statement="updateProduct"/> <flushOnExecute statement="deleteProduct"/> <property name=”reference-type” value=”SOFT” /> </cacheModel> SOFT 이 참조타입은 결과물이 현재 사용중이지 않고 메모리가 다른 객체를 위해 필요한 경우에 메모리가 바닥나는 가능성을 제거할것입니다. 어쨌든 이것은 할당되고 좀더 중요한 객체에 유효하지 않는 메모리에 대해 대부분 공격적인 참조타입이 아닙니다.

  20. sqlMap 캐쉬타입들 <cacheModel id="product-cache" type="MEMORY"> <flushInterval hours="24"/> <flushOnExecute statement="insertProduct"/> <flushOnExecute statement="updateProduct"/> <flushOnExecute statement="deleteProduct"/> <property name=”reference-type” value=”STRONG” /> </cacheModel> STRONG 이 참조타입은 명시적을 캐쉬가 삭제될때까지메모리내에 저장된 결과물을 보증합니다. 이것은 1) 매우작음, 2) 절대적으로 정적, and 3) 매우 종종 사용되는 결과에 좋습니다. 장점은 특수한 쿼리를 위해 매우 좋은 성능을 보입니다. 단점은 결과물에 의해 사용되는 메모리가 필요할 때 다른 객체를 위해 메모리를 반환하지 않습니다.

  21. sqlMap • xmlResultName • <select id="getPerson" parameterClass=”int” resultClass="xml" xmlResultName=”person”> • SELECT • PER_ID as id, • PER_FIRST_NAME as firstName, • PER_LAST_NAME as lastName, • PER_BIRTH_DATE as birthDate, • PER_WEIGHT_KG as weightInKilograms, • PER_HEIGHT_M as heightInMeters • FROM PERSON WHERE PER_ID = #value# • </select> • 위 select statement는 다음 구조의 XML객체를 생성합니다. • <person> • <id>1</id> • <firstName>Clinton</firstName> • <lastName>Begin</lastName> • <birthDate>1900-01-01</birthDate> • <weightInKilograms>89</weightInKilograms> • <heightInMeters>1.77</heightInMeters> • </person>

  22. sqlMap • 원시타입 파라미터 • 원시타입 래퍼객체(String, Integer, Date등등)를 파라미터로 사용 할 수 있습니다. • <statement id=”insertProduct” parameter=”java.lang.Integer”> • select * from PRODUCT where PRD_ID = #value# • </statement>

  23. sqlMap Map 타입 파라미터 <statement id=”insertProduct” parameterClass=”java.util.Map”> select * from PRODUCT where PRD_CAT_ID = #catId# and PRD_CODE = #code# </statement>

  24. sqlMap • result maps • <resultMap id=”resultMapName” class=”some.domain.Class” [extends=”parent-resultMap”]> • <result property=”propertyName” column=”COLUMN_NAME” • [columnIndex=”1”] [javaType=”int”] [jdbcType=”NUMERIC”] • [nullValue=”-999999”] [select=”someOtherStatement”] • /> • <result ……/> • <result ……/> • <result ……/> • </resultMap>

  25. sqlMap • 내포하는 Result Maps • <statement id=”getProduct” resultClass=”com.ibatis.example.Product”> • select • PRD_ID as id, • PRD_DESCRIPTION as description • from PRODUCT • where PRD_ID = #value# • </statement>

  26. sqlMap • 원시타입의 Results (이를 테면 String, Integer, Boolean) • <resultMap id=”get-product-result” class=”java.lang.String”> • <result property=”value” column=”PRD_DESCRIPTION”/> • </resultMap> • 좀더 간단한 접근법은 맵핑된statement안에서 간단하게 result class를 사용하는것입니다.(“as”키워드를 사용해서 “value”라는 칼럼별칭을 사용하는 것을 주의깊게 보세요.) • <statement id=”getProductCount” resultClass=”java.lang.Integer”> • select count(1) as value • from PRODUCT • </statement>

  27. sqlMap • Map Results • <resultMap id=”get-product-result” class=”java.util.HashMap”> • <result property=”id” column=”PRD_ID”/> • <result property=”code” column=”PRD_CODE”/> • <result property=”description” column=”PRD_DESCRIPTION”/> • <result property=”suggestedPrice” column=”PRD_SUGGESTED_PRICE”/> • </resultMap> • 간단하게 사용하는 법 • <statement id=”getProductCount” resultClass=”java.util.HashMap”> • select * from PRODUCT • </statement>

  28. sqlMap • 복합(Complex) Properties (이를 테면 사용자에 의해 정의된 클래스의 프라퍼티) • <resultMap id=”get-product-result” class=”com.ibatis.example.Product”> • <result property=”id” column=”PRD_ID”/> • <result property=”description” column=”PRD_DESCRIPTION”/> • <result property=”category” column=”PRD_CAT_ID” select=”getCategory”/> • </resultMap> • <resultMap id=”get-category-result” class=”com.ibatis.example.Category”> • <result property=”id” column=”CAT_ID”/> • <result property=”description” column=”CAT_DESCRIPTION”/> • </resultMap> • <statement id=”getProduct” parameterClass=”int” resultMap=”get-product-result”> • select * from PRODUCT where PRD_ID = #value# • </statement> • <statement id=”getCategory” parameterClass=”int” resultMap=”get-category-result”> • select * from CATEGORY where CAT_ID = #value# • </statement>

  29. sqlMap • N+1 Selects (1:1) 피하기 • 복합 프로퍼티 사용시 퍼포먼스에 악영향이 있을 수 있습니다. • 해결방법(조인사용) • <resultMap id=”get-product-result” class=”com.ibatis.example.Product”> • <result property=”id” column=”PRD_ID”/> • <result property=”description” column=”PRD_DESCRIPTION”/> • <result property=”category.id” column=”CAT_ID” /> • <result property=”category.description” column=”CAT_DESCRIPTION” /> • </resultMap> • <statement id=”getProduct” parameterClass=”int” resultMap=”get-product-result”> • select * from PRODUCT, CATEGORY where PRD_CAT_ID=CAT_ID and PRD_ID = #value# • </statement> • 하지만 위의 조인이 항상 좋은것만은 아니니 주의해서 사용해야 합니다.

  30. sqlMap • 복합 키또는 다중 복합 파라미터프라퍼티 • <resultMap id=”get-order-result” class=”com.ibatis.example.Order”> • <result property=”id” column=”ORD_ID”/> • <result property=”customerId” column=”ORD_CST_ID”/> • … • <result property=”payments” column=”{itemId=ORD_ID, custId=ORD_CST_ID}” select=” getOrderPayments”/> • </resultMap> • <statement id=”getOrderPayments” resultMap=”get-payment-result”> • select * from PAYMENT • where PAY_ORD_ID = #itemId# • and PAY_CST_ID = #custId# • </statement>

  31. sqlMap • 동적으로 맵핑되는Statements • <select id="dynamicGetAccountList” cacheModel="account-cache” resultMap="account-result" > • select * from ACCOUNT • <isGreaterThanprepend="and" property="id" compareValue="0"> • where ACC_ID = #id# • </isGreaterThan> • order by ACC_LAST_NAME • </select>

  32. sqlMap • 바이너리 조건적인 요소 • <isEqual> • 프라퍼티와값 또는 다른 프라퍼티가 같은지 체크. • <isNotEqual> • 프라퍼티와값 또는 다른 프라퍼티가 같지 않은지 체크. • <isGreaterThan> • 프라퍼티가값 또는 다른 프라퍼티보다 큰지 체크. • <isGreaterEqual> • 프라퍼티가값 또는 다른 프라퍼티보다 크거나 같은지 체크. • <isLessThan> • 프라퍼티가값 또는 다른 프라퍼티보다 작은지 체크. • <isLessEqual> 프라퍼티가 값 또는 다른 프라퍼티보다 작거나 같은지 체크.사용법 예제: • <isLessEqualprepend=”AND” property=”age” compareValue=”18”> • ADOLESCENT = ‘TRUE’ • </isLessEqual>

  33. sqlMap • 단일 조건적인 요소 • <isPropertyAvailable> • 프라퍼티가유효한지 체크(이를 테면 파라미터빈의 프라퍼티이다.) • <isNotPropertyAvailable> • 프라퍼티가유효하지 않은지 체크(이를 테면 파라미터의 프라퍼티가 아니다.) • <isNull> • 프라퍼티가null인지 체크 • <isNotNull> • 프라퍼티가null이 아닌지 체크 • <isEmpty> • Collection, 문자열 또는 String.valueOf() 프라퍼티가null이거나 empty(“” or size() < 1)인지 체크 • <isNotEmpty> • Collection, 문자열 또는 String.valueOf() 프라퍼티가null이 아니거나 empty(“” or size() < 1)가 아닌지 체크. • Example Usage: • <isNotEmptyprepend=”AND” property=”firstName” > • FIRST_NAME=#firstName# • </isNotEmpty>

  34. sqlMap • 다른 요소들 • <isParameterPresent> • 파라미터객체가 존재(not null)하는지 보기위해 체크. • <isNotParameterPresent> • 파라미터객체가 존재하지(null) 않는지 보기위해 체크. • Example Usage: • <isNotParameterPresentprepend=”AND”> • EMPLOYEE_TYPE = ‘DEFAULT’ • </isNotParameterPresent>

  35. sqlMap • 다른 요소들 • <iterate> • java.util.List타입의 프라퍼티 반복 • 사용법 예제: • <iterate prepend=”AND” property=”userNameList” open=”(” close=”)” conjunction=”OR”> • username=#userNameList[]# • </iterate> • 주의: iterator요소를 사용할 때 리스트 프라퍼티의 끝에 중괄호[]를 포함하는 것은 중요합니다. 중괄호는 문자열처럼 리스트를 간단하게 출력함으로부터 파서를유지하기 위해 리스트처럼 객체를 구별합니다.

  36. 트랜잭션 • 트랜잭션 • private Reader reader= new Resources.getResourceAsReader ("com/ibatis/example/sqlMap-config.xml"); • private SqlMapClientsqlMap = XmlSqlMapBuilder.buildSqlMap(reader); • public updateItemDescription (String itemId, String newDescription) throws SQLException { • try { • sqlMap.startTransaction (); • Item item = (Item) sqlMap.queryForObject ("getItem", itemId); • item.setDescription (newDescription); • sqlMap.update ("updateItem", item); • sqlMap.commitTransaction (); • } finally { • sqlMap.endTransaction();//반드시 해줘야 합니다. • } • }

  37. 트랜잭션 • 트랜잭션(두개의트랜젝션) • SQL Map설정파일에 <transactionManager> type 속성을 “JTA”로 설정해야만 하고 “UserTransaction”을 SqlMapClient인스턴스가UserTransaction인스턴스를찾는곳에 전체 JNDI이름에 셋팅해야합니다. • try { • orderSqlMap.startTransaction(); • storeSqlMap.startTransaction(); • orderSqlMap.insertOrder(…); • orderSqlMap.updateQuantity(…); • storeSqlMap.commitTransaction(); • orderSqlMap.commitTransaction(); • } finally { • try { • storeSqlMap.endTransaction(); • } finally { • orderSqlMap.endTransaction(); • } • }

  38. 배치 배치(Batches) sqlMap.startBatch(); //…execute statements in between sqlMap.executeBatch();

  39. SqlMapClient SqlMapClient주요 메소드 public intinsert(String statementName, Object parameterObject) throws SQLException public intupdate(String statementName, Object parameterObject) throws SQLException public intdelete(String statementName, Object parameterObject) throws SQLException public Object queryForObject(String statementName,ObjectparameterObject) throws SQLException public Object queryForObject(String statementName,ObjectparameterObject, Object resultObject) throws SQLException public List queryForList(String statementName, Object parameterObject) throws SQLException

  40. SqlMapClient SqlMapClient주요 메소드 public List queryForList(String statementName, Object parameterObject, intskipResults, intmaxResults) throws SQLException public List queryForList(String statementName,ObjectparameterObject, RowHandlerrowHandler) throws SQLException public PaginatedListqueryForPaginatedList(String statementName,ObjectparameterObject, intpageSize) throws SQLException public Map queryForMap (String statementName, Object parameterObject,StringkeyProperty) throws SQLException public Map queryForMap (String statementName, Object parameterObject,StringkeyProperty, String valueProperty) throws SQLException

  41. SqlMapClient SqlMapClient예제 Example 1: Update (insert, update, delete) 수행하기. sqlMap.startTransaction(); Product product = new Product(); product.setId (1); product.setDescription (“Shih Tzu”); int rows = sqlMap.insert (“insertProduct”, product); sqlMap.commitTransaction();

  42. SqlMapClient SqlMapClient예제 Example 2: 객체를 위한 쿼리 수행하기. (select) sqlMap.startTransaction(); Integer key = new Integer (1); Product product = (Product)sqlMap.queryForObject (“getProduct”, key); sqlMap.commitTransaction();

  43. SqlMapClient SqlMapClient예제 Example 3: 미리 할당된 result객체를 가지고 객체를 위한 쿼리 수행하기. sqlMap.startTransaction(); Customer customer = new Customer(); sqlMap.queryForObject(“getCust”, parameterObject, customer); sqlMap.queryForObject(“getAddr”, parameterObject, customer); sqlMap.commitTransaction();

  44. SqlMapClient SqlMapClient예제 Example 4: 리스트를 위한 뭐리 수행하기. (select) sqlMap.startTransaction(); List list = sqlMap.queryForList (“getProductList”, null); sqlMap.commitTransaction();

  45. SqlMapClient SqlMapClient예제 Example 5: 자동 커밋 // When startTransaction is not called, the statements will // auto-commit. Calling commit/rollback is not needed. int rows = sqlMap.insert (“insertProduct”, product);

  46. SqlMapClient SqlMapClient예제 Example 6: 결과 경계를 가지고 리스트를 위한 쿼리 수행하기. sqlMap.startTransaction(); List list = sqlMap.queryForList (“getProductList”, null, 0, 40); sqlMap.commitTransaction();

  47. SqlMapClient • SqlMapClient예제 • Example 7: RowHandler를 가지고 쿼리 수행하기. (select) • public class MyRowHandler implements RowHandler { • public void handleRow (Object object, List list) throws SQLException{ • Product product = (Product) object; • product.setQuantity (10000); • sqlMap.update (“updateProduct”, product); • // Optionally you could add the result object to the list. • // The list is returned from the queryForList() method. • } • } • sqlMap.startTransaction(); • RowHandlerrowHandler = new MyRowHandler(); • List list = sqlMap.queryForList (“getProductList”, null, rowHandler); • sqlMap.commitTransaction();

  48. SqlMapClient SqlMapClient예제 Example 8: 페이지 처리된 리스트를 위한 쿼리 수행하기. (select) PaginatedList list = sqlMap.queryForPaginatedList (“getProductList”, null, 10); list.nextPage(); list.previousPage();

  49. SqlMapClient SqlMapClient예제 Example 9: map을 위한 쿼리 수행하기. sqlMap.startTransaction(); Map map = sqlMap.queryForMap (“getProductList”, null, “productCode”); sqlMap.commitTransaction(); Product p = (Product) map.get(“EST-93”);

  50. Logging Log4j log4j.properties # Global logging configuration log4j.rootLogger=ERROR, stdout # SqlMap logging configuration... #log4j.logger.com.ibatis=DEBUG #log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG #log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG #log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG #log4j.logger.java.sql.Connection=DEBUG #log4j.logger.java.sql.Statement=DEBUG #log4j.logger.java.sql.PreparedStatement=DEBUG #log4j.logger.java.sql.ResultSet=DEBUG # Console output... log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] -%m%n

More Related