Hi,
I am using JPA to persist entities into a database. I know how to use JPA but I don't understand how its interfaces work. Take the following example:
This is a very simple
JSF backing bean. The PersonEntityJpaController class persists the PersonEntity entity to the db. My question is about the injected EntityManagerFactory and UserTransaction. It's my understanding that when you use these your application server (glassfish in my case) "injects" instances of these interfaces into your class. But how can you instantiate an interface? I understand that you can use an interface as a reference type but I am not sure how this works here. A segment of the PersonEntityJpaController class is below:
The UserTransaction and EntityManagerFactory are passed to the constructor and the EntityManagerFactory creates an EntityManager using its createEntityManager method. You can also see that the UserTransaction begin, commit, etc. method being called. My problem is understanding how these methods work when all these are interfaces?? Interfaces only outline methods, they don't write how they are perform (for want of a better
word). So what class(s) have implemented these interfaces and their methods, and where are they?
Sorry for the long winded question!
Thanks,
Alan