Tag: 加入

左边连接spring数据jpa和querydsl

我正在使用spring数据jpa和querydsl并且如何编写简单的好查询以便左连接两个表。 假设我有一个Project实体和一个在Project中定义了OneToMany关系的Task实体,我想做类似的事情: select * from project p left join task t on p.id = t.project_id where p.id = searchTerm select * from project p left join task t on p.id = t.project_id where t.taskname = searchTerm 在JPQL中,它应该是: select distinct p from Project p left join p.tasks t where t.projectID = searthTerm select distinct p from […]

Java:使用分隔符连接基元数组

假设,我有一个数组: int[] arr = new int[] {1, 2, 3, 4, 5, 6, 7}; 我需要使用分隔符连接其元素,例如” – ” ,因此我应该得到这样的字符串: “1 – 2 – 3 – 4 – 5 – 6 – 7” 我怎么能这样做? PS:是的,我知道这个和这个post,但它的解决方案不适用于一系列基元。