It's true that JPA may generate additional queries while dealing with OneToOne relationships, and this is a subject where users usually ask for help in online forums and Q&A websites. This article will help you understand why this phenomenon occurs.
We will jump right through a practical example, since this is the best way to describe the scenario:
Suppose that we are representing a corporation with the typical Employees table. It happens that some of the employees may have a working Vehicle assigned to them. Since not all employees have an assigned vehicle, we conclude that the vehicle is in fact optional (this is an important detail).
A data sample of the just described scenario could look like the following:
Some people, including me, have been struggling with merging entities from different modules (jars) into a single persistence unit (especially with JavaSE, for instance here JPA 2.0: Adding entity classes to PersistenceUnit *from different jar* automatically ). Based on the answers there is no easy direct way to do that. One of solutions is to list all classes from all jars in single persistence unit file, but that's not really elegant. I might have accidentally found another way. Generally all my entity classes are mapped using annotations. As for the solution: persistence.xml can include multiple XML mapping files
"Beware of these common mistakes when implementing transactions in the Java platform
Transaction processing should achieve a high degree of data integrity and consistency. This article, the first in a series on developing an effective transaction strategy for the Java platform, introduces common transaction pitfalls that can prevent you from reaching this goal. Using code examples from the Spring Framework and the Enterprise JavaBeans (EJB) 3.0 specification, series author Mark Richards explains these all-too-common mistakes."
"How to improve JPA performance by 1,825%
The Java Persistence API (JPA) provides a rich persistence architecture. JPA hides much of the low level dull-drum of database access, freeing the application developer from worrying about the database, and allowing them to concentrate on developing the application. However, this abstraction can lead to poor performance, if the application programmer does not consider how their implementation affects database usage.
JPA provides several optimization features and techniques, and some pitfalls waiting to snag the unwary developer. Most JPA providers also provide a plethora of additional optimization features and options. In this blog entry I will explore the various optimizations options and techniques, and a few of the common pitfalls."
"JPA specification defines few types of EntityManagers / Persistence Contexts. We can have:
extended and transactional-scoped EntityManagers,
container-managed or application-managed EntityManagers.
JTA or resource-local EntityManager,
Besides the above distinction, we also have two main contexts in which EntityManager / Persistence Context can exist – Java EE and Java SE. Not every option is available for Java EE and not every is possible in Java SE. In the rest of the post I refer to the Java EE environment.
Ok, so before we’ll proceed to the real topic of this post — which is the behaviour of the EntityManager in Java EE created manually using EntityManagerFactory — let’s just shortly describe the above EM types."
Le projet Spring-Data-JPA est l'un des projets de Spring reposant sur Spring-Data.
Spring-Data réduit considérablement le coût économique de la couche d'accès aux données relationnelles ou NoSQL.
Il simplifie l'accès aux bases de données SGBDR ou de type NoSQL.