[英]How to use LocalTime in select query with Quarkus Panache
[英]How to select only certain fields with Quarkus Panache?
Quarkus
使用Panache
简化了 Hibernate ORM 的映射。
这是我的entity
和PanacheRepository
的示例:
@Entity
public class Person {
@Id @GeneratedValue private Long id;
private String firstName;
private String lastName;
private LocalDate birth;
private Status status;
}
@ApplicationScoped
public class PersonRepository implements PanacheRepository<Person> {
// example
public Person findByName(String name){
return find("name", name).firstResult();
}
// ! and this is what I tried, but it's not possible to do it this way
// all the methods return Person or something of type Person like List<Person>
// so basically this won't even compile
public List<String> findAllLastNames() {
return this.find("select p.lastName from Person p").list();
}
}
所有指南都解释了如何编写不同的查询,但不清楚如何 select 只有某些属性。
如果我不需要整个Person
lastName
,而是我数据库中所有人的姓氏?
是否有可能 select 仅使用Quarkus Panache
的某些属性?
目前这是不可能的,您可以订阅这个关于 Hibernate 投影的问题: https://github.com/quarkusio/quarkus/issues/6261
不要犹豫投票(+1 反应)并提供反馈。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.