当 Bean 具有带有@Formula注释的属性时,findRowCount 不起作用
2022-09-04 23:28:10
我有以下课程:
@Entity
@Table(name = "clients")
public class Client extends Model {
@Id
public int id;
@Formula(select = "inv.some_data",
join = "left join (select 1 as some_data) as inv")
public int someData;
public static Finder<String, Client> find =
new Finder<String, Client>(String.class, Client.class);
public static int countClientsWithData() {
return Client.find.where().gt("someData", 0).findRowCount();
}
}
它有场(游戏框架将自动生成 getter 和 setter)。并在子句中使用此字段。现在,如果我这样做someData
countClientsWithData
where
int count = Client.countClientsWithData();
它会在尝试执行查询时抛出NullPointerException
select count(*) from clients t0 where inv.some_data > ?
看起来像不识别注释中的加入。关于如何解决这个问题的任何想法?findRowCount
@Formula
更新问题:缩小了要呼叫的问题范围。findRowCount