From: <leg...@at...> - 2003-05-27 23:56:12
|
Message: A new issue has been created in JIRA. --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-108 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-108 Summary: Mapping non-static inner classes Type: New Feature Status: Unassigned Priority: Minor Project: Hibernate2 Components: core Assignee: Reporter: Gunther Schadow Created: Tue, 27 May 2003 6:55 PM Updated: Tue, 27 May 2003 6:55 PM Environment: any Description: It would be nice if Hibernate could handle true inner classes. For example, say you have a Person with several addresses: class Person { long id, String name, List/*<Address>*/ addresses class Address { String value; String purpose; } ... } whereas the database contains the two tables: CREATE TABLE Person ( id LONG NOT NULL PRIMARY KEY, name VARCHAR, ) CREATE TABLE PersonAddress ( personId LONG NOT NULL REFERENCES Person(id), value VARCHAR, purpose VARCHAR, PRIMARY KEY(personId, purpose); ) and the mapping file would contain <class name="Person" table="Person"> <id name="id" type="long">...</id> <property name="name" type="string"/> <bag name="addresses" lazy="true" table="PersonAddress"> <key column="personId"/> <composite-element class="Person$Address"> <property name="value" column="value" type="string"/> <property name="purpose" column="purpose" type="string"/> </composite-element> </bag> </class> Since personId is NOT NULL in the PersonAddress table, we know that we allways will have a Person if we load a PersonAddress, and, since PersonAddress is mapped as a composite element, we can't even load a Person$Address alone without having a Person in hand. Therefore all requirements for creating non-static inner classes are fulfilled. Workaround is of course to use a static inner class in which the implicit association to the parent class is made explicit. Since non-static inner classes are a proper idiom of Java, the goal of "persistence for idiomatic java" makes proper handling of non-static inner classes highly desirable. --------------------------------------------------------------------- JIRA INFORMATION: 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/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |