July 2017
Intermediate to advanced
466 pages
11h 24m
English
Let's stop here for a moment. Remember our discussion of the Java Persistence API (JPA) and database? Here is where we see that coming in. With the JPA, interactions with the database are done via the EntityManager interface, which we retrieve from the cleverly named EntityManagerFactory. It is important to note that the EntityManager instances are not thread-safe, so they should not be shared between threads. That's why we didn't create one in the constructor and pass it around. This is, of course, a local variable, so we need not worry about that too much until, and if, we decide to pass it as a parameter to another method, which we are doing here. As we will see in a moment, everything happens in the same ...
Read now
Unlock full access