You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Guillaume Chauvet (JIRA)" <ji...@apache.org> on 2013/10/14 15:12:42 UTC
[jira] [Closed] (OPENJPA-2274) Annotations & interface methods
[ https://issues.apache.org/jira/browse/OPENJPA-2274?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Guillaume Chauvet closed OPENJPA-2274.
--------------------------------------
Resolution: Not A Problem
http://stackoverflow.com/questions/4204868/jpa-doesnt-support-interfaces-well-implications
> Annotations & interface methods
> -------------------------------
>
> Key: OPENJPA-2274
> URL: https://issues.apache.org/jira/browse/OPENJPA-2274
> Project: OpenJPA
> Issue Type: Improvement
> Reporter: Guillaume Chauvet
>
> Dear OpenJPA team,
> I tested a peculiar use of annotations on methods declared into an interface :
> public interface EntityHeader {
> public long getId();
> }
> public interface EntityHistorizable<E extends EntityHeader> {
> /* .... other methods ....*/
> @PostLoad
> public void postLoad();
>
> @PrePersist
> public void prePersist();
> }
> public class Task implements Serializable, EntityHistorizable<Task>, EntityHeader {
> /* .... Implementations .... */
> @Override
> public void postLoad() {
> System.out.println("postLoad");
> }
> @Override
> public void prePersist() {
> System.out.println("prePersist");
> }
> }
> When I perform a persist/find operation on the "Task" entity, OpenJPA don't execute postLoad/prePersist methods because annotations are applied in the interface. I don't know if it's a good practice, but it will be useful in the case who want to provide a "pattern" interface, for example.
--
This message was sent by Atlassian JIRA
(v6.1#6144)