Hibernate derived property with xml mapping

萝らか妹 提交于 2019-12-01 19:05:48
Xtreme Biker

I finally achieved it with this code:

<property name="_LastRevisionDate"
        formula="(select MAX(rev.start_date) from trevision rev where rev.id_detectable = id_detectable and rev.status != 'DRAFT')"
        type="date" />

Where id_detectable is my current entity key column.


UPDATE

Another workaround is to use a DB view to obtain the last revision date. Then, there's the choice to map the Entity against that view instead of the original table.

What is the sql syntax error? Did you try replacing _Id with id?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!