0

I have a table with 2 columns for phone number(area code and number). When I define entity, I can do it with 2 different variable to match column names. However, when i use it in jparepository, I want to search with a phone number (which will be a single string of area code and number).

Is ther a way to group area code and number while defining the entity to have a single variable to hold combined data of 2 columns?

@Entity public class Person{ private String areaCode; private String number; }

1 Answers1

0

You can use JPQL CONCAT method like below to achieve that.

CONCAT(p.areaCode, '', p.number)

Refer this

Alien
  • 15,141
  • 6
  • 37
  • 57