# Multiple condition Search using CriteriaBuilder

**URL:** <https://discourse.hibernate.org/t/multiple-condition-search-using-criteriabuilder/924>\
**Category:** Hibernate ORM\
**Created:** [June 14, 2018, 5:02pm UTC](https://discourse.hibernate.org/t/multiple-condition-search-using-criteriabuilder/924 "2018-06-14T17:02:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhiraj07](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/dhiraj07/32/175_2.png) [@dhiraj07](https://discourse.hibernate.org/u/dhiraj07)\
**Post date:** [June 14, 2018, 5:02pm UTC](https://discourse.hibernate.org/t/multiple-condition-search-using-criteriabuilder/924/1 "2018-06-14T17:02:56Z")

</div>

Hii,

I am using hibernate version: 5.2.17.Final  
and MYSQL as a DB

Here my generated query is:  
select propertyde0.PropertyId as col\_0\_0, propertyde0.OwnerName as col\_1\_0, propertyde0.City as col\_2\_0, propertyde0.State as col\_3\_0 from PropertyDetail propertyde0 where propertyde0.State=‘CA’ and propertyde0.IsPropertyClaimed=‘0’ and propertyde0.IsDeleted=‘0’ and propertyde0.City=‘BRENTWOOD’ and (propertyde0.OwnerName like ‘%VE%’)

I am searching in 2.7 GB table.

I have added Indexing on columns.

Some time it searches the desired result but sometimes it gives timeouts.

is there any suggestions on how to resolve this problem

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [June 14, 2018, 5:24pm UTC](https://discourse.hibernate.org/t/multiple-condition-search-using-criteriabuilder/924/2 "2018-06-14T17:24:13Z")

</div>

Show us the execution plan in the JSON format for this query.

---

<div class="post-metadata">

**Author:** ![dhiraj07](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/dhiraj07/32/175_2.png) [@dhiraj07](https://discourse.hibernate.org/u/dhiraj07)\
**Post date:** [June 14, 2018, 5:57pm UTC](https://discourse.hibernate.org/t/multiple-condition-search-using-criteriabuilder/924/3 "2018-06-14T17:57:28Z")

</div>

@vlad, Could not get your point.

It gives connection timeout.

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [June 14, 2018, 6:32pm UTC](https://discourse.hibernate.org/t/multiple-condition-search-using-criteriabuilder/924/4 "2018-06-14T18:32:49Z")

</div>

Here’s a link with what you need to do to get the execution plan

[https://dev.mysql.com/doc/refman/8.0/en/explain.html](https://dev.mysql.com/doc/refman/8.0/en/explain.html)

---

<div class="post-metadata">

**Author:** ![dhiraj07](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/dhiraj07/32/175_2.png) [@dhiraj07](https://discourse.hibernate.org/u/dhiraj07)\
**Post date:** [June 30, 2018, 9:31am UTC](https://discourse.hibernate.org/t/multiple-condition-search-using-criteriabuilder/924/5 "2018-06-30T09:31:05Z")

</div>

Hii,  
it works for me.  
Thanks for your support.
