是否可以在 Hibernate @Subselect 注释中使用 HQL?

Is it Possible to use HQL in Hibernate @Subselect annotation?

如果我在@Subselect 中使用SQL,我会得到结果。是否可以在此注释中使用 HQL?

@Entity
@Subselect("select * from Foo_table")
public class FooView

喜欢

@Entity
@Subselect("select a from FooEntity a")
public class FooView

我想这是不可能的,因为根据 https://docs.jboss.org/hibernate/orm/3.6/reference/en-US/html/mapping.html#mapping-declaration-class

There is no difference between a view and a base table for a Hibernate mapping. This is transparent at the database level, although some DBMS do not support views properly, especially with updates. Sometimes you want to use a view, but you cannot create one in the database (i.e. with a legacy schema). In this case, you can map an immutable and read-only entity to a given SQL subselect expression using @org.hibernate.annotations.Subselect

并且它会直接作为DB的查询语句执行,没有HQL层和从HQL到纯HQL的转换SQL...但是你可以玩它并测试