I am new to JPA and stuck with fetching the records from DB. What I am doing is
Transaction Begin
Go to Class A-> Create Object A using EntityManager persist method.
Go to Class B-> Create Object B using EntityManager persist method.
Go to Class C-> try to fetch the Object A using EntityManager createQuery method and here I am passing some parameters(Don't have the Primary key so using this).
then query.getResultList() this give me the empty result list.
Transaction commit
But when I check the DB after committing I got the expected result. I believe I got the empty list because I persist the record "A" but not committed into DB. If this is the case please help me in fetching that record.
Are you sure all of that operation was part of the same transaction? Also, what is the transaction isolation on the JDBC connection that JPA is using? It depends on how the connection/datasource is configured.