0

EJB + Eclipselink integration in ZK

asked 2013-06-05 10:51:14 +0800

tizianodg gravatar image tizianodg
1

I need to create structured applications in many projects with JPA implemented by EclipseLink.

I would refer to these projects (and possibly EJB) from a ZK project, but I can not get a reference to EntityManager (eg. using annotations like @PersistenceContext) within my ZK project.

I would avoid creating it with an EntityManagerFactory, because I'm not sure about its lifecycle (if I instantiate it, then I need to release it?). Instead I would prefer that the management of the release of the EntityManager were to be executed by the J2EE context in which we are working.

After checking in many forums, and in the ZK documentation, i found that has always been used Spring instead of EJB + EclipseLink. Are there particular motivations?

Example: Eclipse JPA Project (EclipseLink 2.4)

@Entity
  public class MyClass implements Serializable {    // JPA Annotated Class
     @Id private int id;
     ...
  }

Eclipse ZK Project (with the previous in the project reference)

public class IndexController extends SelectorComposer<Component> {
    @Wire Intbox edtId;
    ...

    @PersistenceContext
    EntityManager em;

    @Listen(Events.ON_CLICK+"=#btnFind")
    public void find() {    
       MyClass c = em.find(MyClass.class, edtId);    // <-- em is null  
    }

  }
delete flag offensive retag edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2013-06-05 10:51:14 +0800

Seen: 31 times

Last updated: Jun 05 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More