@Table("employee")
public class Employee {
@Name
@Prev(els = @EL("$me.initUUID()"))
@Column("id")
private String id;
@Column("username")
private String username;
@Column("password")
private String password;
@Column("e_id")
private String eid;
@One(target=EmployeeInfo.class,field="eid",key="id")
private EmployeeInfo employeeInfo;
@Table("employeeinfo")
public class EmployeeInfo {
@Name
@Prev(els=@EL("$me.initUUID()"))
@Column("id")
private String id;
@Column("name")
private String name;
//提交处理
@At("/submit")
public View submit(@Param("::user.")User user,@Param("::employeeInfo.")EmployeeInfo ei){
//为用户添加时间戳
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
user.setTime(sdf.format(date));
//将提交的数据存入数据库中
if(Strings.isEmpty(user.getId())){ //若id为空,则该操作为添加新用户,插入信息
user.setEmployeeInfo(ei);
dao.insertWith(user,"ei");
}else{ //若id不为空,则该操作为编辑用户,更新信息
dao.updateWith(user,"ei");
}
return new ServerRedirectView("/system/admin/index");
}
执行这段操作后,console显示
log4j: 2018-03-29 15:12:34,620 [http-nio-8080-exec-7] DEBUG org.nutz.dao.impl.sql.run.NutDaoExecutor - // NOT SQL // ElFieldMacro=$me.initUUID()
log4j: 2018-03-29 15:12:34,629 [http-nio-8080-exec-7] DEBUG org.nutz.dao.impl.sql.run.NutDaoExecutor - INSERT INTO users(id,username,password,e_id,r_id,time) VALUES(?,?,?,?,?,?)
| 1 | 2 | 3 | 4 | 5 | 6 |
|--------------------------------------|-------|--------|------|--------------------------------------|---------------------|
| a349d7ab-d413-40d3-b43e-9ff771b2ddd2 | admin | 123456 | NULL | 8acffc23-71e8-479f-9e77-a7db75b8357d | 2018-03-29 15:12:34 |
For example:> "INSERT INTO users(id,username,password,e_id,r_id,time) VALUES('a349d7ab-d413-40d3-b43e-9ff771b2ddd2','admin','123456',NULL,'8acffc23-71e8-479f-9e77-a7db75b8357d','2018-03-29 15:12:34') "
进行几次验证,user和ei能够获取页面的值,在进行插入的时候,没有成功,程序也没有报错,这是为什么呢?