Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含 2 列电话号码(区号和号码)的表格。当我定义实体时,我可以使用 2 个不同的变量来匹配列名。但是,当我在 jparepository 中使用它时,我想用一个电话号码进行搜索(这将是一个区号和号码的字符串)。
有没有办法在将实体定义为具有单个变量来保存 2 列的组合数据时对区号和号码进行分组?
@Entity public class Person{ private String areaCode; private String number; }
您可以使用如下所示的 JPQL CONCAT 方法来实现。
CONCAT(p.areaCode, '', p.number)
参考这个