[hibernate-issues] [Hibernate-JIRA] Commented: (ANN-527) reference a target entity (in a collection) by entity name

IK (JIRA) noreply at atlassian.com
Fri Nov 7 02:56:18 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/ANN-527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=31642#action_31642 ] 

IK commented on ANN-527:
------------------------

Hi,

we need this feature to. In our case, the application is made of different modules with domain-logic. Each module has an interface and implemententation package. The public part of the domain-object is in die interface package. The compile-time dependencies are configured that modules can only depend on interfaces of other modules. Therefore module A has only access to the interface definitions on module B. If a Domain-Object in module A has a relationship to a Domain-Object in module B, the reference to the Domain-Object in module B cannot be a Domain Implementation-Class in our case. Therefore, with the "target-entity" annotation, we get a compile-error in module A.

Solution is actually pretty easy. Patch in persistence-api-*.jar the Files:

OnetoOne, OneToMany, ManyToOne and ManyToMany to Support "EntityTargetName" (as String) Annotation.

And patch in hibernate-annotations-*.jar the class:

org.hibernate/annotation/cfg/AnnotationBinder, in case TargetEntity is void, to use the TargetEntityName Annotation (and load the class with class.forName(...)). 

Would be nice to the something like that in the main development branch.

> reference a target entity (in a collection) by entity name
> ----------------------------------------------------------
>
>                 Key: ANN-527
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-527
>             Project: Hibernate Annotations
>          Issue Type: New Feature
>          Components: binder
>            Reporter: Armin Haaf
>
> It is only possible to reference a targetEntity by class.
> @ManyToMany(targetEntity = TestImpl.class)
> List<Test> myList;
> This makes it impossible to exchange TestImpl.class implemention by another implemention by the mappings definition.
> It would be helpful to reference a targetEntity by name.
> @ManyToMany(targetEntityName = "Test")
> This would help a lot to implement moduls and frameworks.
> Another way to support this would be to search for a implementation of the collection elements (which are typically Interfaces) in the mapped entities 

-- 
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