Skip to main content

[jpa-spec issues] [JIRA] Commented: (JPA_SPEC-41) @Target Declaration for @Embedded

  • From: "Paul Benedict (JIRA)" < >
  • To:
  • Subject: [jpa-spec issues] [JIRA] Commented: (JPA_SPEC-41) @Target Declaration for @Embedded
  • Date: Fri, 11 Apr 2014 15:02:49 +0000 (UTC)
  • Auto-submitted: auto-generated


    [ 
https://java.net/jira/browse/JPA_SPEC-41?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=374313#action_374313
 ] 

Paul Benedict commented on JPA_SPEC-41:
---------------------------------------

I agree with the analysis that adding @Embedded(target=...) would be better 
than a new annotation. It aligns nicely with @Column(targetEntity=...)

> @Target Declaration for @Embedded
> ---------------------------------
>
>                 Key: JPA_SPEC-41
>                 URL: https://java.net/jira/browse/JPA_SPEC-41
>             Project: jpa-spec
>          Issue Type: New Feature
>            Reporter: mquasten
>            Assignee: ldemichiel
>
> Using an @Embedded inside an entity or an other Embedded  isn't posible 
> using an Interface for the Declaration of the field.
> @Entity(name="NaturalPerson")
> public class NaturalPersonImpl implements NaturalPerson{
>       @Column(length=50)
>       private final String firstname;
>         @Column(length=50)
>       private final String lastname;
>       
>       
>       
>       @Embedded
>       @Target(NativityImpl.class) // This annotation is a hibernate 
> Annotation, not a JPA Annotation, it shoud be take over in JPA
>       private final Nativity nativity;
>       
>       public NaturalPersonImpl(final String firstname, final String 
> lastname, final Nativity nativity) {
>               this.firstname=firstname;
>                 this.lastname=lastname
>               this.nativity=nativity;
>       }
>         ...
> }
> ...
> entityManager.persist(new NaturalPersonImpl("Kylie", "Minogue", new 
> NativityImpl("Melborne", new GregorianCalendar(1968, 4, 28).getTime( ) );
> Instead of the @Target (as it is done in native Hibernate) something like  
> @Embedded(target=NativityImpl.class) is posible too (as it is done for the 
> normal Relations @OneToMany, @ManyToOne , @ManyToMany
> HardCoding the Implementation is bad, because Mocking with Mockito, 
> EasyMock and so on  is limited, when the implementations use final  for 
> example. Using the Hibernate Annotations avoid exchange interchangeability 
> of the persistence provider. Specifieng abstract Classes in the target 
> definition may me not possible, because the type can not be resoved reading 
> the values back from database (because it isn't defined like by entities  
> where the implementation is stored in the database). But simple cases 
> without polymorhism should be possible.  

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://java.net/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


[jpa-spec issues] [JIRA] Commented: (JPA_SPEC-41) @Target Declaration for @Embedded

Paul Benedict (JIRA) 04/11/2014
 
 
Close
loading
Please Confirm
Close