Jakartaee vs Spring vs Java SE with JPA

Asked

Viewed 55 times

1

Speak for me, baby?

Reading the Oracle documentation I found the following excerpt:

@Persistencecontext protected Entitymanager entityManager;

Hence the EJB container will inject a standard Unit persistence there. This also works with Spring. But I have questions about JPA without being Spring or EJB. I’ve done several demos using persistence.xml, but what does that mean? When using JPA I’m necessarily using JEE? JPA is from JEE, right? Can I use parts of the JEE within the JSE in this case? You know where I see a conceptual introduction to this subject?

1 answer

1

Jee covers a lot of things. One of them is the specification (not implementation) JPA, which was made inspired by the Hibernate ORM framework, and later Hibernate adapted to it and implemented this specification (but also maintained particularities that do not follow JPA, I do not know if in the same version).

Persistence doesn’t just involve ORM, it can even be done in text-files, so I don’t know if they only deal with ORM or not. But surely the ORM part has a great weight in specification.

You can adopt a JPA implementation (which can be Hibernate or other) in your JSE application to do data persistence. I don’t think you can say that it’s turned into a JEE app because the JEE are several things and one of them that seems central to me is the Ejbs and the properties they have running in a container, and that will not be being used in the case, but its application will be adopting a specification that is part of the JEE, in this case the persistence model.

(I may be talking nonsense, you said that the EJB container injects the persistence Unit (which must therefore be an EJB), right? So no longer understand anything rs. Even so I think I would classify as JEE its application if it used other JEE features than just persistence. Or at least if you used JPA/Hibernate to also be using Ejbs and not just Hibernate. Oh I don’t know...).

Introduction to this I think would be things like reading the specification of the JEE, the JPA, and the Hibernate page. Wikipedia in English can also help. And also read about the difference between JPA and Hibernate; the non-JA version of the latter may have optimizations for certain databases or for the processing of data in general that JPA for trying to be more generalist does not offer.

P.S.: From Spring I don’t know anything, anyone who wants to complement is welcome. And I may have said something outdated.

  • "which should therefore be an EJB" yes. Spring also provides a container and can also inject the persistence unit. However, when I use JPA with JSE, I need to instantiate PU with Entitymanagerfactory, we use that famous Jpautils with emf as Singleton created in a Static block. But I remembered that web application with Tomcat is also not JEE, it is only a part of JEE, so I already understood what I wanted...

  • Tomcat has that story of implementing only the Web Profile, which if I’m not mistaken was created precisely to make this kind of differentiation (as opposed to a "full profile" of the JEE I believe).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.