views:

1241

answers:

2

The example at the end of hibernate section 5.1.3 does not show an example on passing parameters.

There is no difference between a view and a base table for a Hibernate mapping. This is transparent at the database level, although some DBMS do not support views properly, especially with updates. Sometimes you want to use a view, but you cannot create one in the database (i.e. 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>

Is it possible? And if so, how?

Thanks, Franz

+1  A: 

I don't think that it is possible, because the mapping file is like a static description.

Ridcully
A: 
Fabio Tani