Wednesday, December 12, 2007

Mapping Hibernate to DB View

There is a problem to map POJO to DB View using Hibernate if you are using also HBM2DLL.
In this case the HBM2DLL would create for each HBM mapping a corresponsing DB table.

To solve the problem -

  • Write HBM as usual
  • Add deletion of the DB table as follow:


DROP TABLE MY_TABLE;


  • Create the view as follow (also in databse object tag)
CREATE VIEW MY_VIEW AS SELECT ....;

Hibernate would write data and read data now with the DB view.

No comments:

Links

 
RSS Feeds Submission Directory