NutzCN Logo
问答 NutzDao insertOrUpdate报错
发布于 2216天前 作者 qq_db31da41 2613 次浏览 复制 上一个帖子 下一个帖子
标签:

BalanceAcceptance 类 继承的基类 id字段有@Id注解,其它字段无@Name @PK 注解
pojo信息如下
userId = {Long@13602} 16
acceptanceTime = {Date@14545} "2018-03-26"
testWay = "自测"
nextTestTime = {Date@14547} "2018-03-29"
expertId = {Long@13540} 5
comment = "111"
tbUser = null
tbExpert = null
id = null

现Id为空,业务逻辑准备实现插入,但

pojo报错Method threw 'java.lang.RuntimeException' exception. Cannot evaluate org.nutz.dao.impl.jdbc.NutPojo.toString()
系统报错 java.lang.RuntimeException: r u kidding me?! It is impossible!

请问大神,这是什么问题?

11 回复
java.lang.RuntimeException: r u kidding me?! It is impossible!
	at org.nutz.lang.Lang.impossible(Lang.java:120)
	at org.nutz.dao.impl.sql.pojo.SingleColumnCondtionPItem.joinParams(SingleColumnCondtionPItem.java:61)
	at org.nutz.dao.impl.jdbc.NutPojo.getParamMatrix(NutPojo.java:82)
	at org.nutz.dao.impl.sql.NutStatement.forPrint(NutStatement.java:197)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:20)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.integration.spring.SpringDaoRunner._run(SpringDaoRunner.java:18)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:82)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252)
	at org.nutz.dao.impl.NutDao.fetch(NutDao.java:617)
	at org.nutz.dao.impl.NutDao.insertOrUpdate(NutDao.java:1085)
	at org.nutz.dao.impl.NutDao.insertOrUpdate(NutDao.java:1067)
	at com.sanfom.common.server.BoostService.saveOrUpdate(BoostService.java:49)

起码得有@Id/@Name/@Pks中的一个

类 继承的父类 的id 属性 并且有@Id 注解,这个不支持么

是不是子类覆盖了id属性??

子类并没有进行覆盖id属性,fetch(id)方法没有问题

贴超类和当前类看看

当前类
public class TbBalanceAcceptance extends ThunderEntity {

@Column
private Long userId;
@Column
private Date acceptanceTime;
@Column
private String testWay;
@Column
private Date nextTestTime;
@Column
private Long expertId;
@Column
private String comment;

@One(field = "userId", key = "id")
private TbUser tbUser;

@One(field = "expertId", key = "id")
private TbExpert tbExpert;

public Long getUserId() {

    return userId;
}

public void setUserId(Long userId) {
    this.userId = userId;
}

public Date getAcceptanceTime() {
    return acceptanceTime;
}

public void setAcceptanceTime(Date acceptanceTime) {
    this.acceptanceTime = acceptanceTime;
}

public Date getNextTestTime() {
    return nextTestTime;
}

public void setNextTestTime(Date nextTestTime) {
    this.nextTestTime = nextTestTime;
}

public Long getExpertId() {
    return expertId;
}

public void setExpertId(Long expertId) {
    this.expertId = expertId;
}

public String getComment() {
    return comment;
}

public void setComment(String comment) {
    this.comment = comment;
}

public TbUser getTbUser() {
    return tbUser;
}

public void setTbUser(TbUser tbUser) {
    this.tbUser = tbUser;
}

public TbExpert getTbExpert() {
    return tbExpert;
}

public void setTbExpert(TbExpert tbExpert) {
    this.tbExpert = tbExpert;
}

public String getTestWay() {
    return testWay;
}

public void setTestWay(String testWay) {
    this.testWay = testWay;
}

}
超类
public class ThunderEntity extends DataBaseEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;

static Security security;

@Id
Long id;


@Column
@Comment("操作人")
@Prev(els = @EL("$me.uid()"))
@ColDefine(type = ColType.AUTO)
private Long opBy;

@Column
@Comment("操作时间")
@Prev(els = @EL("$me.now()"))
@ColDefine(type = ColType.TIMESTAMP)
private Date opAt;

public Date now() {
    return new Date();
}

public Long uid() {
    try {
        return security.uid();
    } catch (Exception e) {
    }
    return null;
}

public Long getId() {
    return id;
}

public Integer getIntId(){
    return Integer.parseInt(String.valueOf(id));
}

public void setId(Long id) {
    this.id = id;
}

public void setIntId(Integer id){
    this.id = Long.parseLong(String.valueOf(id));
}

public void setOpBy(Long opBy) {
    this.opBy = opBy;
}

public Date getOpAt() {
    return opAt;
}

public void setOpAt() {
    this.opAt = new Date();
}

public void setOpAt(Date opAt) {
    this.opAt = opAt;
}

public String uuid() {
    return R.UU32().toLowerCase();
}

public static void setSecurity(Security security){
    ThunderEntity.security = security;
}

}

翻了翻代码, 发现是没有对包装类型的@Id进行判断,所以fetch的时候就报错

话说... 判断一下getId() 是否为null, 然后调用insert 或者 update吧...

以后会支持么?
我暂时先这么处理了...,谢谢大神o(* ̄▽ ̄*)o

会, 报个issue吧

添加回复
请先登陆
回到顶部