使用休眠条件获取记录为行的记录 [英] Fetch records which columms as rows using hibernate criteria

查看:111
本文介绍了使用休眠条件获取记录为行的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a table with columns as rows.
Now I want to apply restriction on multiple rows with "and" condition.how can we do this using hibernate criteria?

Example :Employee table

Pk  ColumnName.   Value
1.          Empid.               10
1        EmpName.           Sachin
1.        Empsalary.          10,000
2         Empid.               20
2       EmpName.           Dhoni
2.        Empsalary.          8000

So now i want to fetch pk's which have 
EmpName as sachin and empsal as 10,000

So it should return pk as 1.





我的尝试:





What I have tried:

I have a table with columns as rows.
Now I want to apply restriction on multiple rows with "and" condition.how can we do this using hibernate criteria?

Example :Employee table

Pk  ColumnName.   Value
1.          Empid.               10
1        EmpName.           Sachin
1.        Empsalary.          10,000
2         Empid.               20
2       EmpName.           Dhoni
2.        Empsalary.          8000

So now i want to fetch pk's which have 
EmpName as sachin and empsal as 10,000

So it should return pk as 1.

推荐答案

您可以使用限制(Hibernate API文档) [ ^ ]调用方法来定义具有AND的多个条件。
You can use Restrictions (Hibernate API Documentation)[^] calling And method to define multiple conditions having AND.


这篇关于使用休眠条件获取记录为行的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆