I just begin my JPA 2.0 studies, and I have this piece of code:
em = SessionFactory.startSession();
tx = em.getTransaction();
My problem is
A session is what you use to interact with the database.
A transaction is used to specify boundaries for the session to operate within.
Essentially, transactions prevent the database from being corrupted by only allowing a session to interact with it at one time. (It's a bit more complicated then that, as you can have many transactions reading from the database, but only one transaction that's writing.)