add mapping inheritance to allow read only classes to be used for reporting
---------------------------------------------------------------------------
Key: HHH-4101
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4101
Project: Hibernate Core
Issue Type: New Feature
Environment: All
Reporter: Ian Hayes
I'm finding that with a number of hibernate mappings I have a simple version of an
entity defined for basic CRUD operations, and then I really need an expanded version of
the same entity that includes all of its associations for reporting process optimization.
For example: I have an entity (e.g. course) that has a number of related sub entities
(e.g. attendees, class times etc) but I don't want to include these sub entities as
properties in the main entity class used for CRUD operations.
To get around this I'm using the following class hierarchy...
Code:
AbstractCourse
|---- Course
|---- CoursePlusBookings
public abstract class AbstractCourse {
private int CourseID;
private String Title;
private String Teacher
}
public class Course extends AbstractCourse {
}
public class Attendee {
private int AttendeeID;
private int CourseID;
private String StudentName;
}
public CoursePlusBookings extends AbstractCourse {
private Set<Attendee> Attendees;
}
Now for all entity level CRUD operations I'm using 'Course' and
'Attendee' separately to add entries to the underlying database. However, for
reporting purposes I want to use 'CoursePlusBookings, which allows me to show a list
of courses with the number of bookings.
Now the only way I can find to support this approach is to have two separate mappings -
one for 'Course' and a second for 'CoursePlusBookings' - both of which map
to the same table. I can't find a way of implementing mapping inheritance to avoid
this duplication. I did raise this question sometime ago on the support forums (see
viewtopic.php?f=1&t=984333) but unfortunately the respondents misunderstood my
question, so I'm asking it again.
I suppose in a way this posting boils down to a question about whether it is possible to
have mapping element associations that are read only in nature. In otherwords if persisted
CoursePlusBookings then the Attendee set would not be persisted as part of that operation.
An alternative approach would be to allow mapping inheritance where a sub class has no
discriminator and is marked as 'read only'. Such read only sub classes could have
multiple properties representing sub entity set associations.
Or is there another way to achieve what I'm after?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira