-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: <subselect>
PostPosted: Fri Apr 28, 2006 4:35 pm 
Regular
Regular

Joined: Tue Mar 21, 2006 11:01 am
Posts: 65
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.