E-One wrote:
Could you explain how this differs from using tables directly? I use native ID generation for PK's.
What I am doing is developing locally using MySQL and tables and I need to use DB2 and views as this is the standard for our company. Since recently we're bound to use Hibernate and I like it a lot, although there's quite some documentation that I find either hard to find or not to be found at all.
Well, doing inserts into views is generally a dangerous practice, but that aside...
Assuming that the views are pretty much one to one mappings to actual tables, you can feel free to use Hibernate as if the views were tables.
However, where things get murky is when you are using views to combine data from multiple tables into some result set. Usually (hopefully), these types of views are intended for read-only, so you shouldn't have to worry about id generation for them. However, as I stated before, Hibernate still requires you to define some set of columns within the view that will be unique (even if *you* don't care about the uniqueness). So in the extreme case, you might have to map all of the columns of the view as a composite key as far as Hibernate is concerned.[/list]