【问题标题】:How to change this statement to detached criteria如何将此语句更改为分离条件
【发布时间】:2012-09-24 03:39:50
【问题描述】:

该语句用于检查用户是否存在于数据库中。

public boolean isExisting(int userId) {
    String sql = "{call isExistingUser(?)}";
    Session session = null;
    boolean isExisting = false;
    try {
        session = getSession();
        SQLQuery query = session.createSQLQuery(sql);
        query.setParameter(0, userId);
        List<?> list = query.list();
        isExisting = list.get(0) != null ? (Boolean) list.get(0) : false;  
    } finally {
        if (session != null)
            session.close();
    }
    return isExisting;
}

这是存储过程:

CREATE DEFINER=cbsadmin@% PROCEDURE isExistingUser(IN userId int) 开始 从 USER_LOGIN_STATUS 中选择 USER_ID,其中 USER_ID = userId; 结束

【问题讨论】:

    标签: sql hibernate detachedcriteria


    【解决方案1】:

    无法在 NHibernate 中使用分离条件查询存储过程。

    您只需要使用 SQL 查询。

    here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多