[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5305) Cannot select elements of a collection mapped as composite-element
Karsten Behrmann (JIRA)
noreply at atlassian.com
Thu Jun 24 18:06:09 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5305?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37578#action_37578 ]
Karsten Behrmann commented on HHH-5305:
---------------------------------------
Apparently the query works (cheers to gbadner on IRC for pointing this out) as
"select elements(el) from Foo f join f.elements el"
The aforementioned syntax should probably have the same effect, though.
This does not initialize <parent> links, as has been previously documented (Java Persistence with Hibernate, 6.2.3, page 253, bottom paragraph).
This is no longer documented in the html reference (8.1 or 8.2 would be appropriate sections, imho)
Alternatively, it should not be hard to initialize parent with at least a proxy, since the <key> column will always be readily available in the same table as the composite properties, no? (and all valid HQL will be joining via there anyway, I think)
> Cannot select elements of a collection mapped as composite-element
> ------------------------------------------------------------------
>
> Key: HHH-5305
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5305
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.5.1, 3.5.3
> Environment: PostgreSQL / hsqldb
> Reporter: Karsten Behrmann
> Original Estimate: 6h
> Remaining Estimate: 6h
>
> The query
> "select el from Foo f join f.elements el"
> produces a SQL select clause for merely "elements.id" (though joined correctly),
> if "elements" is a set of composite-element.
> It should rather select for all properties of the composite-element.
> Effect:
> - If there is no column called "id", the query fails database parse
> (provoke by explicitly doing <key column="fooID" />)
> - If the composite-element has more than one property, hibernate ResultSet parsing fails asking for missing col_0_1_
> - If the composite-element has one property, assignment-compatible with whatever the database column "id" happens to be, the query succeeds, returning a list of elements with the property set to the value of "id".
> So it seems like support is almost there. This may be a regression, or a not-quite-completed feature. Succeeding quietly with bad data is Not Good, but the case should not occur much in practice (composite-element with one property is not very useful).
> Workaround: explicitly select each property, as in
> "select el.name, el.created, el.importance from Foo f join f.elements el"
> and manually instantiate the element class.
> (This seems to still fail on <any> properties, but that is probably an unrelated problem)
--
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list