NutzCN Logo
问答 数据库插入 问题 打印的sql 但库中无数据
发布于 2775天前 作者 Rekoe 2016 次浏览 复制 上一个帖子 下一个帖子
标签:

控制台打印了插入sql 但数据库中没有数据

[05:46:54:989] [DEBUG] - org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) - Exception when parser SQL sql, skip cache detect!! SQL=RUN 
[05:46:54:989] [DEBUG] - org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - // NOT SQL // ElFieldMacro=$me.date()
[05:46:54:989] [DEBUG] - org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:110) - Exception when parser SQL sql, skip cache detect!! SQL=RUN 
[05:46:54:990] [DEBUG] - org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - // NOT SQL // ElFieldMacro=$me.now()
[05:46:54:990] [DEBUG] - org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:147) - sql = INSERT INTO set_meal(wx_id,createTime,ct,is_del,is_complete) VALUES(?,?,?,?,?) , tables = [set_meal]
[05:46:54:990] [DEBUG] - org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - INSERT INTO set_meal(wx_id,createTime,ct,is_del,is_complete) VALUES(?,?,?,?,?) 
    |                            1 |                   2 |                   3 |     4 |     5 |
    |------------------------------|---------------------|---------------------|-------|-------|
    | oqqXTjqUSKScwbaBRulNWtqq-UOI | 2017-05-18 05:46:54 | 2017-05-18 00:00:00 | false | false |
  For example:> "INSERT INTO set_meal(wx_id,createTime,ct,is_del,is_complete) VALUES('oqqXTjqUSKScwbaBRulNWtqq-UOI','2017-05-18 05:46:54','2017-05-18 00:00:00',false,false) "
[05:46:54:994] [DEBUG] - org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:194) - Clear Cache=set_meal

单查询控制台后

mysql> SELECT * FROM set_meal  WHERE wx_id='oqqXTjqUSKScwbaBRulNWtqq-UOI' AND ct='2017-05-18 00:00:00' AND is_del=false;
Empty set (0.00 sec)

还有个问题 我没有配置 set_meal缓存 却提示清理了这个表的缓存
ioc 配置

var ioc = {
	conf : {
		type : "org.nutz.ioc.impl.PropertiesProxy",
		fields : {
			paths : [ "custom/" ]
		}
	},
	dataSource : {
		factory : "$conf#make",
		args : [ "com.alibaba.druid.pool.DruidDataSource", "db." ],
		type : "com.alibaba.druid.pool.DruidDataSource",
		events : {
			create : "init",
			depose : 'close'
		}
	},
	dao : {
		type : "org.nutz.dao.impl.NutDao",
		args : [ {
			refer : "dataSource"
		} ],
		fields : {
			interceptors : [ {
				refer : "cacheExecutor"
			}, "log" ]
		}
	},
	cacheExecutor : {
		type : "org.nutz.plugins.cache.dao.DaoCacheInterceptor",
		fields : {
			cacheProvider : {
				refer : "cacheProvider"
			},
			cachedTableNames : [ "t_user", "wx_user" ],
			enableWhenTrans : false,
			db : "MYSQL"
		}
	},
	cacheProvider : {
		type : "org.nutz.plugins.cache.dao.impl.provider.EhcacheDaoCacheProvider",
		fields : {
			cacheManager : {
				refer : "cacheManager"
			}
		},
		events : {
			create : "init"
		}
	},
	dataSourceDetail : {
		factory : "$conf#make",
		args : [ "com.alibaba.druid.pool.DruidDataSource", "detail." ],
		type : "com.alibaba.druid.pool.DruidDataSource",
		events : {
			create : "init",
			depose : 'close'
		}
	},
	daoDetail : {
		type : "org.nutz.dao.impl.NutDao",
		args : [ {
			refer : "dataSourceDetail"
		} ],
		fields : {
			interceptors : [ {
				refer : "cacheExecutor"
			}, "log" ]
		}
	}
};
4 回复

@wendal

db.defaultAutoCommit=true

设置这个属性的时候容易出这样的问题

@wendal
貌似不是这个配置的问题 我打印了返回的对象
对象已经获得自增的值了

public void makeOrder(String openid) {
		SetMeal meal = new SetMeal();
		meal.setWxId(openid);
		meal = dao.insert(meal);
		System.out.println(Json.toJson(meal));
	}
{
   "id": 126,
   "wxId": "oqqXTjqUSKScwbaBRulNWtqq-UOI",
   "createTime": "2017-05-18 07:24:31",
   "ct": "2017-05-18 00:00:00",
   "delete": false,
   "complete": false
}

连错数据库了吧

问题已找到
描述下过程
数据库插入数据的时候 有个字段存的属性是timestemp类型的 存入前时间被转换为了 天 也就是 2017-05-18 00:00:00
结果插入数据库后 这个属性值变成了2017-05-18 00:00:01 导致这条按照2017-05-18 00:00:00 查询的数据一直没有 所以现象就成了一楼描述的那个情况
结帖

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