# Hibernate CASE WHEN expression not using arithmetic operation

**URL:** <https://discourse.hibernate.org/t/hibernate-case-when-expression-not-using-arithmetic-operation/1671>\
**Category:** Hibernate ORM\
**Created:** [November 8, 2018, 11:54am UTC](https://discourse.hibernate.org/t/hibernate-case-when-expression-not-using-arithmetic-operation/1671 "2018-11-08T11:54:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhyhang](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/zhyhang/32/571_2.png) [@zhyhang](https://discourse.hibernate.org/u/zhyhang)\
**Post date:** [November 8, 2018, 11:54am UTC](https://discourse.hibernate.org/t/hibernate-case-when-expression-not-using-arithmetic-operation/1671/1 "2018-11-08T11:54:46Z")

</div>

org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: \* near line 1, column 46 [select case when p.name like ‘person%’ then 2\*p.id else p.id end from com.ipinyou.mip.mdb.model.Person p]

---

<div class="post-metadata">

**Author:** ![zhyhang](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/zhyhang/32/571_2.png) [@zhyhang](https://discourse.hibernate.org/u/zhyhang)\
**Post date:** [November 8, 2018, 1:10pm UTC](https://discourse.hibernate.org/t/hibernate-case-when-expression-not-using-arithmetic-operation/1671/2 "2018-11-08T13:10:48Z")

</div>

hibernate orm 5.3.7

```auto
select 
    case when p.name like ‘person%’ 
    then 2*p.id 
    else p.id end 
from com.ipinyou.mip.mdb.model.Person p

```

---

<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:** [November 10, 2018, 11:26am UTC](https://discourse.hibernate.org/t/hibernate-case-when-expression-not-using-arithmetic-operation/1671/3 "2018-11-10T11:26:58Z")

</div>

I created [HHH-13095](https://hibernate.atlassian.net/browse/HHH-13095) for it and submitted a PR for updating the docs.

You need to use parenthesis to wrap the arithmetic expression:

```auto
select 
    case when p.name like ‘person%’ 
    then (2*p.id) 
    else p.id end 
from com.ipinyou.mip.mdb.model.Person p

```
