有没有办法在@Formula注释中使用它之前知道表别名?

时间:2017-05-22 08:06:46

标签: java hibernate alias

@Formula(customer_table_alias + ".count + 1")
private int count;

我需要知道Hibernate将为customer表设置哪个别名。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

我认为唯一的方法是使用subselect

@Formula("(select count+1 as new_count from customer_table ct where ct.id=current_id)")
private int count;

其中current_id是实体的id列

相关问题