Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.5
Mapping documents:na
Code between sessionFactory.openSession() and session.close():na
Full stack trace of any exception that occurs:na
Name and version of the database you are using:Oracle 9.2
The generated SQL (show_sql=true):na
Debug level Hibernate log excerpt:na
The Hibernate manual for version 3.0.5 (section 6.1.3) contains the following text:
Quote:
subselect (optional): Maps an immutable and read-only entity to a database subselect. Useful if you want
to have a view instead of a base table, but don't. See below for more information.
"below" appears to be this.
Quote:
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
I'm confused by the "don't". It isn't clear what the manual thinks I shouldn't do. Should I not use views or not use the subselect functionality? Or is it even appropriate to my use case?
Here is my basic situation. I want to map a certain class to the database. All fields of the class map to columns in a single database table except for one field which comes from another table via an outer join - the value of this field may be null. This last field should be thought of as immutable as far as the object I am mapping is concerned. It may be changed, but not through the object I am mapping.
Do I want two Hibernate classes mapped - one which does not contain the joined column - for writing these objects - and another which does contain the joined column - for reads? Or is there there a good way to have it both ways with a single object?