0

I have the following Java code:

public T findByPrimaryKey(Object key, Class clazz) throws CPDPersistenceException {

try {
final EntityManager em = getEntityManager();
T t  = em.find(clazz,key);
//etc.

The "find" method always returns null although I can see the entry in the table. The EntityManager object I created is not null. I added a print statement to be sure of this. There was one null entry in the table, and I fixed that, and yet the problem persists. There are three classes of objects created by this application, and only one, the "process" object has this problem as it passes through this piece of code. Does anybody have any idea? I perused similar questions about this problem on this site, and I do not see a solution to my problem among the answers given so far. Thanks for your time.

calvinnme
  • 17
  • 6
  • Why not look at the JPA providers log, and then you can see the SQL it executes to determine the object ??? –  Aug 08 '18 at 16:57
  • Do I necessarily have a JPA provider log, or does that need to be set up? I inherited this code, and that is why I am asking. – calvinnme Aug 08 '18 at 18:56
  • You're using JPA, so you're using a JPA provider. And whichever JPA provider you selected has a log, and you can configure it. Step number 1 in writing/debugging a JPA application. Only you know which provider you use, and from that you can search the internet on how to configure it –  Aug 09 '18 at 06:07
  • There is a post about this, and I understand adding the line to persistence.xml, but the post points to a whole section about a programmatic piece of all of this if using hibernate, and it is not too clear: [How to view queries in SQL made by JPA](https://stackoverflow.com/questions/4362876/how-to-view-the-sql-queries-issued-by-jpa) I am using Hibernate...in what piece of code does this configuration code go anyways? Thanks for your time – calvinnme Aug 09 '18 at 16:12

0 Answers0