1

This statement is to check if the user is existing in the database.

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;
}

This is the stored procedure:

CREATE DEFINER=cbsadmin@% PROCEDURE isExistingUser(IN userId int) BEGIN SELECT USER_ID FROM USER_LOGIN_STATUS WHERE USER_ID = userId; END

kwan_ah
  • 1,061
  • 1
  • 12
  • 18

1 Answers1

0

It is not possible to query a Stored procedure using detached criteria in NHibernate.

You need to use SQL query only.

See here.

Community
  • 1
  • 1
Rockstart
  • 2,337
  • 5
  • 30
  • 59