Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Target Declaration for @Embedded #41

Closed
lukasj opened this issue Dec 17, 2012 · 6 comments
Closed

@Target Declaration for @Embedded #41

lukasj opened this issue Dec 17, 2012 · 6 comments

Comments

@lukasj
Copy link
Contributor

lukasj commented Dec 17, 2012

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.

@lukasj
Copy link
Contributor Author

lukasj commented Dec 17, 2012

@glassfishrobot Commented
Reported by mquasten

@lukasj
Copy link
Contributor Author

lukasj commented Apr 11, 2014

@glassfishrobot Commented
paulusbenedictus said:
I agree with the analysis that adding @Embedded(target=...) would be better than a new annotation. It aligns nicely with @column(targetEntity=...)

@lukasj
Copy link
Contributor Author

lukasj commented May 5, 2017

@glassfishrobot Commented
This issue was imported from java.net JIRA JPA_SPEC-41

@lukasj
Copy link
Contributor Author

lukasj commented Aug 31, 2018

@gavinking
Copy link
Contributor

We recently deprecated the above-mentioned @Target annotation in Hibernate 6, and I don't think we should add it to JPA.

I think we should close this issue.

@gavinking
Copy link
Contributor

Anyway, this is from 2012, and has no votes. I'm going to close it.

@gavinking gavinking closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants