聚合资讯    词典    My blog    Tag   
hi! | 关于
专注于Java技术、开源项目、项目管理

标签 - 分类 : 全部 | UNIX | 随笔 | 数据库 | Java技术 | 网摘文章

关于用Hibernate映射数据库视图View,在Hibernate官方文档里提到过,如下:

There is no difference between a view and a base table for a Hibernate mapping, as expected this is transparent at the database level (note that some DBMS don't support views properly, especially with updates). Sometimes you want to use a view, but can't create one in the database (ie. with a legacy schema). In this case, you can map an immutable and read-only entity to a given SQL subselect expression:

<class name="Summary">
    <subselect>
        select item.name, max(bid.amount), count(*)
        from item
        join bid on bid.item_id = item.id
        group by item.name
    </subselect>
    <synchronize table="item"/>
    <synchronize table="bid"/>
    <id name="name"/>
    ...
</class>

Declare the tables to synchronize this entity with, ensuring that auto-flush happens correctly, and that queries against the derived entity do not return stale data. The <subselect> is available as both as an attribute and a nested mapping element

标签 :




置评

标题
正文
HTML : b, i, blockquote, br, p, pre, a href="", ul, ol, li
姓名
电邮地址
网站
记住我 是  否 

电邮地址将不会发表在公开网页上,您留下的电邮地址仅用于本文有新评论时通知您(以后可以随时拿掉).

回接到 http://www.searchfull.net:80/blog/addTrackBack.action?entry=1197352735559