简体   繁体   中英

JPA multiple search in two fields by string

I have input string, like that "part of name and part of surName"
And in my entity I have two fields: name and surName. And i want fold this two fields name + " " + surName and then search my text "part of name and part of surName" in this new String from two fields.
Can I create this query in JPA? Or i must choose separately this fields and then already on Java BE, fold them and start search by string also on BE?

select p from Person p 
where concat(p.name, ' ', p.surname) like concat('%', :part, '%')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM