[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4417) Add annotation support for UserCollectionType
Steve Ebersole (JIRA)
noreply at atlassian.com
Mon Mar 5 10:54:48 EST 2012
[ https://hibernate.onjira.com/browse/HHH-4417?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45828#comment-45828 ]
Steve Ebersole commented on HHH-4417:
-------------------------------------
Even in {{hbm.xml}} binding, it is just assumed that whatever is named as a {{collection-type}} deals with the matching Java type named by the containing {{<list/>}}, {{<set/>}}, etc.
As far as the corollary to determining difference between {{<list/>}}, {{<set/>}}, etc {{CollectionBinder}} on the annotation side already contains the appropriate logic. As Endre points out, there is a minor issue WRT the "Commons Annotations" stuff and/or the ReflectionManager where custom collection implementations (not the collection type implementations!) are not recognized as collections, even if the custom collection implementation extends a JDK one. So you have to expose this as a java collection ATM :( As an example:
{code:borderStyle=solid}
// given:
class MyCustomList<X> implements java.util.List<X> {
...
}
// and:
class MyCustomListType implements UserCollectionType {
...
}
// works fine
@OneToMany(...)
@CollectionType( type="MyCustomListType" )
public List getOrders()
// erros due to mentioned limitation
@OneToMany(...)
@CollectionType( type="MyCustomListType" )
public MyCustomList getOrders()
{code}
> Add annotation support for UserCollectionType
> ---------------------------------------------
>
> Key: HHH-4417
> URL: https://hibernate.onjira.com/browse/HHH-4417
> Project: Hibernate ORM
> Issue Type: Patch
> Components: annotations
> Environment: All versions, database agnostic
> Reporter: Douglas Sjoquist
> Assignee: Steve Ebersole
> Priority: Minor
> Fix For: 4.1.1
>
> Attachments: UserCollectionTypeAnnotation.zip
>
> Original Estimate: 0.5h
> Time Spent: 0.45h
> Remaining Estimate: 0.5h
>
> Add an annotation to specify the UserCollectionType for a OneToMany or ManyToMany.
> The annotation is named CollectionTypeInfo, perhaps better named UserCollectionType, but I didn't know the standards for naming classes.
> The change to AnnotationBinder is minor and is delineated by '//dwsjoquist//' comment lines.
> Usage:
> @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
> @JoinColumn(name = "id")
> @CollectionTypeInfo(name = "examples.MyUserCollectionType")
> public List<ExampleAttribute> getExampleAttributes() {
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list