1.
config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties resource="mybatis/config.properties" />
<environments default="development">
<environment id="development">
<transactionManager type="JDBC" />
<!-- JDBC: 커밋, 롤백처리 / MANAGED -->
<!-- POOLED : 매번초기화안함, 빠른 응답 -->
<dataSource type="POOLED"><!-- UNPOOLED, POOLED, JNDI -->
<property name="driver" value="${driver}" />
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</dataSource>
</environment>
<!-- <environment id="development02"> <transactionManager type="JDBC" />
<dataSource type="POOLED"> <property name="driver" value="oracle.jdbc.driver.OracleDriver"
/> <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:xe" /> <property
name="username" value="hr" /> <property name="password" value="hr" /> </dataSource>
</environment> -->
</environments>
<!-- SQL 문장이 기술되는 Mapper파일 -->
<mappers>
<mapper class="dao.ProductMapper" />
</mappers>
</configuration>
2.
String resource = "org/mybatis/builder/mybatis-config.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder(); SqlSessionFactory factory = builder.build(inputStream);
3.
| Method |
| Each of these annotations represents the actual SQL that is to be executed. They each take an array of strings (or a single string will do). If an array of strings is passed, they are concatenated with a single space between each to separate them. This helps avoid the "missing space" problem when building SQL in Java code. However, you're also welcome to concatenate together a single string if you like. Attributes: value, which is the array of Strings to form the single SQL statement. |
4.
@Results({ @Result(property = "no", column = "no"), @Result(property = "item", column = "item"),
@Result(property = "price", column = "price"), @Result(property = "regdate", column = "regdate")
// property와 Column이 다를 때 활용
})
5.
@Repository 는 DAO위에 걸어놓는다.
6.
@Component("myaddress")의 의미는 <bean id = myaddress = com.test.Address/>과 같다.
7.
annotation을 통해 exception Customizing을 간편화시킬 수 있다.
8.
댓글