6月 13号

Caused by: java.sql.SQLException: ORA-00904: "THIS_"."WAREHOUSE": invalid identifier
一开始我以为是 因为是 warehouse的类型被我设置错误了 。结果到数据库里发现是 因为我再数据库里根本就没有这个字段造成的

    if (warehouse == null) {
            wh = null;
        } else {
            wh = masterWHDAO.findById(warehouse);
        }
dao.findbyid(warehouse):warehouse can't be null


        c.add(Expression.isNull("warehouse"));注意isnull跟isempty的区别。后者是指集合是否为空



openSessionInView常出现

<!---->1.                     <!---->InvalidDataAccessApiUsageException: Write operations <o:p></o:p>

are not allowed in read-only mode

save,add,update,remove开头的方法拥有可写的事务,如果当前有某个方法,如命名为importExcel(),则因没有transaction而没有写权限,这时若方法内有insert,update,delete操作的话,则需要手动设置flush modelFlush.AUTO,<o:p></o:p>

<!---->1.                     <!----> session.setFlushMode(FlushMode.AUTO); <o:p></o:p>

<!---->2.                     <!----> session.save(user); <o:p></o:p>

<!---->3.                     <!----> session.flush();


 


 

    private void listAllChildrenIds(Session session, List list, String id) {
        String CHILDREN_SQL = "select entity.id from TemplateCategoryEntity entity where entity.parentId=:id";
        Query query = session.createQuery(CHILDREN_SQL);
        query.setString("id", id);
        List children = query.list();
        for (int i = 0; children != null && i < children.size(); i++) {
            String child = ((String) children.get(i));
            log.debug("found children:" + child);
            list.add(child);
            listAllChildrenIds(session, list, child);
        }
    }
}
<o:p></o:p>

你可能感兴趣的:(DAO,sql,C++,c,C#)