作為開源的Orm對象映射框架
一
二
log
log
log
三
package org
public class Student { private Long id;
private String name;
private String subject;
private Long score;
public Long getId() { return id; }
public void setId(Long id) { this
public String getName() { return name; }
public void setName(String name) { this
public Long getScore() { return score; }
public void setScore(Long score) { this
public String getSubject() { return subject; }
public void setSubject(String subject) { this
四
<?xml version=
<!DOCTYPE sqlMap
PUBLIC
<sqlMap namespace=
<typeAlias alias=
<resultMap class=
<result property=
<result property=
<result property=
<result property=
<select id=
select * from student </select>
<select id=
select * from student where id=#id# </select> <insert id=
insert into student(id
</insert>
<update id=
update student set name=#name#
</update>
<delete id=
delete from student where id=#id#
</delete>
</sqlMap>
五
<?xml version=
<!DOCTYPE sqlMapConfig
PUBLIC
<sqlMapConfig>
<sqlMap resource=
六
package org
import java
import org
import com
public class StudentDao extends SqlMapClientDaoSupport implements Idao{
public void delete(Long id) {
this
public Object findbyId(Long id) {
return this
public List getAll() {
return (List)this
public Object doInSqlMapClient(SqlMapExecutor sqlMapper) throws SQLException { return sqlMapper
}
});
}
public void save(Object o) {
this
public void update(Object o) {
this
}
public static void main(String[] args) throws IOException {
Resource re=new ClassPathResource(
XmlBeanFactory xml=new XmlBeanFactory(re);
StudentDao student=(StudentDao)xml
Student stu=new Student();
stu
stu
stu
stu
student
}
}
七
<?xml version=
<beans>
<bean id=
class=
<property name=
<value>oracle
</property> <property name=
<value>jdbc:oracle:thin:@localhost:
</property>
<property name=
<value>terry</value>
</property>
<property name=
<value>terry</value>
</property>
</bean>
<bean id=
<property name=
<property name=
</bean>
<bean id=
<property name=
</bean>
<!
<bean id=
<!
<property name=
<property name=
<props>
<prop key=
<prop key=
<prop key=
</props>
</property>
</bean>
<bean class=
<property name=
<list>
<value>*Dao</value>
</list>
</property>
<property name=
<list>
<value>transactionIterceptor</value>
</list>
</property>
</bean>
<bean id=
<property name=
</bean>
</beans>
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28705.html