We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
但如果改成嵌套的post请求,单用户时可以避免这种情况,多用户时则仍然有隐患。 $.post('jsp/ware/wareinfo_countlike', data, function() { $.post('jsp/ware/wareinfo_bypagelike', data, function() { ... }) })
@IocBean @at("/jsp/ware") public class WareInfoAction { // 模糊查询条数 @at("/wareinfo_countlike") public Object wareinfoCountLike(String value){ return BasicDao.getInstance().searchPageByLike(WareInfo.class, value,"isdel",0); }
// 模糊查询分页 @At("/wareinfo_bypagelike") public List<WareInfo> wareinfoByPageLike(String value,int currentPage,int pageSize){ List<WareInfo> list = BasicDao.getInstance().searchPageByLike(WareInfo.class,value,"isdel",0,currentPage,pageSize); // 获取一级关联表 for(WareInfo qc : list){ // 以下两个查询有时候会被选择性地忽略 BasicDao.getInstance().getDao().fetchLinks(qc, "trayinfo"); BasicDao.getInstance().getDao().fetchLinks(qc, "orderbom"); } return list; }
}
public class BasicDao {
... private static NutzBasicDao uniqueInstance = new NutzBasicDao(); private Dao dao; private NutzBasicDao() { dao = new NutIoc(new JsonLoader("/config/dao.js")).get(Dao.class); } public static NutzBasicDao getInstance() { return uniqueInstance; } public Dao getDao() { return dao; } public <T> int searchPageByLike(Class<T> c, String value, String fieldName, Integer value1) { Entity<T> entity = dao.getEntity(c); List<MappingField> fields = entity.getMappingFields(); SqlExpressionGroup group = null; for (MappingField f : fields) { if (!f.isId()) { SqlExpression e = Cnd.exps(f.getColumnName(), "LIKE", "%" + value + "%").and(fieldName, "=", value1); if (group == null) { group = Cnd.exps(e); } else { group.or(e); } } } return dao.count(c, Cnd.where(group)); } public <T> List<T> searchPageByLike(Class<T> c, String value, String fieldName, Integer value1, int currentPage, int pageSize) { Entity<T> entity = dao.getEntity(c); List<MappingField> fields = entity.getMappingFields(); SqlExpressionGroup group = null; for (MappingField f : fields) { if (!f.isId()) { SqlExpression e = Cnd.exps(f.getColumnName(), "LIKE", "%" + value + "%").and(fieldName, "=", value1); if (group == null) { group = Cnd.exps(e); } else { group.or(e); } } } Pager pager = dao.createPager(currentPage, pageSize); return dao.query(c, Cnd.where(group), pager); } ...
The text was updated successfully, but these errors were encountered:
findLink 并非nutz内部的方法, 请自查
Sorry, something went wrong.
把这段改一下试试
for(WareInfo qc : list){ wiDao.findLink(qc, "trayinfo");// 获取一级关联表 wiDao.findLink(qc.getTrayinfo(), "stockLocationInfo"); wiDao.findLink(qc, "orderbom"); wiDao.findLink(qc.getOrderbom(),"order"); // 通过中间表获取二级关联表 wiDao.findLink(qc.getOrderbom(),"drawInfo"); rlist.add(qc); }
改成
for(WareInfo qc : list){ wiDao.findLink(qc, null);// 获取一级关联表 wiDao.findLink(qc.getTrayinfo(), null); wiDao.findLink(qc.getOrderbom(),null); rlist.add(qc); }
最终是通过在Setup.init中对所有pojo类进行getEntity操作解决
原因可能是NutEntity的生成过程并没有做到线程同步,待查
确定有这问题,是带关联属性的Entity, 在未完成全部操作的情况下,将自身set到EntityHolder,所以另外一个线程就会拿到一个不完整的Entity
8236bf0
wendal
No branches or pull requests
$.post('jsp/ware/wareinfo_countlike', data, function() { ... })
$.post('jsp/ware/wareinfo_bypagelike', data, function() { ... })
这样请求时,后台会出现有时读数据有时不读的情况。
但如果改成嵌套的post请求,单用户时可以避免这种情况,多用户时则仍然有隐患。
$.post('jsp/ware/wareinfo_countlike', data, function() {
$.post('jsp/ware/wareinfo_bypagelike', data, function() { ... })
})
DEBUG时发现Nutz在visitOne中的getList时是从cache中获取关联对象的,是不是由于两个post请求并发导致的问题?其它
@IocBean
@at("/jsp/ware")
public class WareInfoAction {
// 模糊查询条数
@at("/wareinfo_countlike")
public Object wareinfoCountLike(String value){
return BasicDao.getInstance().searchPageByLike(WareInfo.class, value,"isdel",0);
}
}
public class BasicDao {
}
The text was updated successfully, but these errors were encountered: