[jboss-user] [EJB 3.0] - Re: entityManager.find() returns null

tboswell do-not-reply at jboss.com
Wed Sep 20 04:37:55 EDT 2006


anonymous wrote : Some of my coworkers have reported similar behaviour of a sporadic nature...simple calls to EntityManager.find(Class,id) return null when the object is clearly in the DB. They've also stated that using EntityManager.createQuery("SELECT obj FROM ClassName obj WHERE obj.id=?") will sometimes return the object immediately after the finder fails. 

I tried getting the object by using a createQuery() myself and still found I was returned a null value. The behaviour I have seen with the find() function has not been sporadic but consistently failing, when the PK was a string.

entityManager.find(Language.class, "en      ");

Ah, yes. This rings a bell...I seem to recall an issue with Oracle padding out char columns with spaces. I will change the column to a varchar and retest.

Thanks for the thoughts everyone.

Tom

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972861#3972861

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972861



More information about the jboss-user mailing list