三、通过Mapping 用XDoclet生成数据库(Oracle)脚本,并建表
drop table rc_gzrz cascade constraints;
create table rc_gzrz (
BS number(19,0) not null,
workDate timestamp,
weather varchar2(24 char),
content clob,
state varchar2(2 char),
orgId number(19,0),
userId number(19,0),
createDate timestamp,
image blob,
primary key (BS)
);
comment on table rc_gzrz is
'工作日志';
comment on column rc_gzrz.BS is
'标识';
comment on column rc_gzrz.workDate is
'工作日期';
comment on column rc_gzrz.weather is
'天气';
comment on column rc_gzrz.content is
'内容';
comment on column rc_gzrz.state is
'状态';
comment on column rc_gzrz.orgId is
'机构id';
comment on column rc_gzrz.userId is
'用户id';
comment on column rc_gzrz.createDate is
'创建日期';
comment on column rc_gzrz.image is
'图片';
四、创建DAO层
/**
* Created by IntelliJ IDEA.
* User: leizhimin
* Date: 2007-11-16
* Time: 10:55:50
* To change this template use File | Settings | File Templates.
*/
public interface WorkNoteDAO extends CommonDAO {
/**
* 根据日期查询工作日志
*
* @param workDate 工作日期
* @param userId 用户id
* @param orgId 机构id
* @param sp 分页对象
* @return List
*/
public List findWorkNoteByDate(Date workDate, Long userId, Long orgId, SplitPage sp);
/**
* 根据状态查询工作日志
*
* @param state 日志状态
* @param userId 用户id
* @param orgId 机构id
* @param sp 分页对象
* @return List
*/
public List findWorkNoteByState(String state, Long userId, Long orgId, SplitPage sp);
}
/**
* Created by IntelliJ IDEA.
* User: leizhimin
* Date: 2007-11-16
* Time: 10:56:00
* To change this template use File | Settings | File Templates.
*/
public class WorkNoteDAOImpl extends CommonDAOImpl implements WorkNoteDAO{
public List findWorkNoteByDate(Date workDate, Long userId, Long orgId, SplitPage sp) {
return null;
}
public List findWorkNoteByState(String state, Long userId, Long orgId, SplitPage sp) {
return null;
}
}
五、创建带JTA事务控制的业务service层
/**
* Created by IntelliJ IDEA.
* User: leizhimin
* Date: 2007-11-16
* Time: 16:43:57
* To change this template use File | Settings | File Templates.
*/
public interface OfficeService {
public void saveWorkNote(WorkNote workNote);
public void updateWorkNote(WorkNote workNote);
}
/**
* Created by IntelliJ IDEA.
* User: leizhimin
* Date: 2007-11-16
* Time: 16:45:54
* To change this template use File | Settings | File Templates.
*/
public class OfficeServiceImpl implements OfficeService{
private WorkNoteDAO workNoteDAO;
public WorkNoteDAO getWorkNoteDAO() {
return workNoteDAO;
}
public void setWorkNoteDAO(WorkNoteDAO workNoteDAO) {
this.workNoteDAO = workNoteDAO;
}
public void saveWorkNote(WorkNote workNote) {
this.workNoteDAO.saveObject(workNote);
}
public void updateWorkNote(WorkNote workNote) {
this.workNoteDAO.updateObject(workNote);
}
}

