分类:
2008-10-16 18:56:19
作为开源的Orm对象映射框架,ibatis是一个线程,学习容易,但是开发相对于hibernate来说的话,就要繁锁些,没有很好的工具支持ibatis所有的配置几乎是通过手写,这样增加了开发者的难度、、好啦,言归正转。下面编写实现。
一、引入spring,ibatis jar包.
二、编写log4j.properties日志文件
log4j.rootLogger=DEBUG,stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%c{1}% - %m%n
log4j.logger.java.sql.PreparedStatement=DEBUG
三、建立Student.java类映象属性
package org.terry.ibatis.pojo;
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.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Long getScore() { return score; }
public void setScore(Long score) { this.score = score; }
public String getSubject() { return subject; }
public void setSubject(String subject) { this.subject = subject; } }
四、编写 student.xml 映象文件
PUBLIC "-//ibatis.apache.org//DTD sql Map 2.0//EN"
"">
insert into student(id,name,subject,score) values(#id#,#name#,#subject#,#score#)
update student set name=#name#,subject=#subject#,score=#score# where id=#id#
delete from student where id=#id#
[1]