我可以映射到这样的查询:
select id,name,address,(select count(*) from account where record_id=id ) as counter
from data where id = :id
Run Code Online (Sandbox Code Playgroud)
目前,我正在使用本机SQL.
class person
{
public virtual long Id{get;set;}
public virtual string Name{get;set;}
public virtual string Address{get;set;}
public virtual long Counter{get;set;}
}
Run Code Online (Sandbox Code Playgroud)
映射:
<property name="Counter" formula="(select count(*) from account where record_id=id )" type="long"/>
Run Code Online (Sandbox Code Playgroud)