[jboss-user] [EJB 3.0] - entityManager.find() returns null
tboswell
do-not-reply at jboss.com
Tue Sep 19 07:05:11 EDT 2006
I am using JBoss 4.0.4-GA with Oracle XE. I have two tables which have strings for their PK and the PK column is named the same as the table:
| CREATE TABLE CURRENCY
| (
| CURRENCY CHAR(8 CHAR) NOT NULL,
| ...
| )
|
| CREATE TABLE LANGUAGE
| (
| LANGUAGE CHAR(8 CHAR) NOT NULL,
| ...
| )
|
This is not ideal I know but it was what I was given to work with.
I find that when using the corresponding entity beans if I use the code:
entityManager.find(Language.class, "en");
this will return me a null value despite the row existing.
This is not a problem when using other entity manager functions A query like entityManager.createQuery("from Language l").getResultList(); will run fine and result all the expected results.
If I call the same code from a test case which is wrapped within a single transaction, I can create an object, insert it and run the same code within the transaction and find it OK.
Only when I am trying to find records already existing outside the transaction do I get the problem.
With DEBUG I have checked the query that Hibernate runs and this runs fine in Oracle but still returns a null to me within my session bean code.
| select language0_.LANGUAGE as LANG1_73_0_, language0_.NAME as NAME73_0_, language0_.SHORT_NAME as SHORT3_73_0_, language0_.CREATED as CREATED73_0_, language0_.INSERTED as INSERTED73_0_, language0_.MODIFIED as MODIFIED73_0_, language0_.ENABLED as ENABLED73_0_, language0_.ENABLED_DATE as ENABLED8_73_0_, language0_.COMMENTS as COMMENTS73_0_, language0_.TESTED as TESTED73_0_, language0_.SUPPORTED as SUPPORTED73_0_, language0_.TESTED_DATE as TESTED12_73_0_, language0_.SUPPORTED_DATE as SUPPORTED13_73_0_, language0_.DEFAULT_TO_LANGUAGE as DEFAULT14_73_0_ from LANGUAGE language0_ where language0_.LANGUAGE='en';
|
I have tried several permutations of changing the table and PK column names but to no avail. For example change the PK name I get this query
| select language0_.LANG_CODE as LANG1_73_0_, language0_.NAME as NAME73_0_, language0_.SHORT_NAME as SHORT3_73_0_, language0_.CREATED as CREATED73_0_, language0_.INSERTED as INSERTED73_0_, language0_.MODIFIED as MODIFIED73_0_, language0_.ENABLED as ENABLED73_0_, language0_.ENABLED_DATE as ENABLED8_73_0_, language0_.COMMENTS as COMMENTS73_0_, language0_.TESTED as TESTED73_0_, language0_.SUPPORTED as SUPPORTED73_0_, language0_.TESTED_DATE as TESTED12_73_0_, language0_.SUPPORTED_DATE as SUPPORTED13_73_0_, language0_.DEFAULT_TO_LANGUAGE as DEFAULT14_73_0_ from LANGUAGE language0_ where language0_.LANG_CODE='en';
|
But the same result.
Is there something I am doing here that Hibernate doesn't expect or is there a known bug?
Thanks,
Tom Boswell
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972537#3972537
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972537
More information about the jboss-user
mailing list