0
我很新的hibernate
我有一個MySQL Query
,我想用Hibernate criteria
Case語句
MySQL查詢才達到相同的輸出:
SELECT *,
(case when status = 'Active'
then 'Can Login'
else 'Not able to login' end) as LoginStatus
FROM UserLoginTable;
我的Hibernate代碼:
SessionFactory sessionFactory = HibernateUtility.getSessionFactory();
Session session_hiber = sessionFactory.openSession();
session_hiber.beginTransaction();
Criteria criteria;
criteria = session_hiber.createCriteria(UserLoginTable.class);
List<UserLoginTable> myUserList = (List<UserLoginTable>)
criteria.list();
如何在上面的代碼中添加Case criteria
。 有什麼辦法嗎? 感謝