RationalDev

more of an aspiration than a claim

Hibernate And Database Views (MyEclipse View Generation)

Hibernate does support usage of views in a similar manner to tables.

It seems that you can configure your hbm files for views much like a table as mentioned in this article.

For my current project I am using MyEclipse and the Hibernate reverse engineering tool. With my view, it is creating a composite key and creating an Id class with all my view columns in it. The main view object has nothing but a reference to and Id. The reasons for this are explained in this thread.

A query like “select id.compositeKeyName from viewName where id.otherCompositeKeyName = ?” is one way to get around this issue. It seems rather strange to me, but I don’t have time to investigate further.

The Hibernate website gives this advice on How can I map a table (or view) with no primary key?.

I think Oracle doesn’t support primary keys in views. Another option is to use JDBC and just read the data and forget about Hibernate.