Java Mailing List Archive

http://www.gg3721.com/

Home » users.openjpa »

EntityManager fetch and query by key behave differently?

Landers, Richard

2009-12-14

Replies: Find Java Web Hosting

Author LoginPost Reply
Hello everyone,

Can anyone clarify my understanding:

I have an entity ("Organization") that I often fetch by it's key (a
String).

In DB2 (v9.5 community) the ID field is a CHAR(10).

I've been using EntityManger.find(Class, String) to do the job for
months.

I was prettying-up URLs in my web layer when I noticed this behavior:

(1) When I pass in: "ORG-10   " (note the trailing spaces) I get an
entity with "ORG-10   " (with trailing spaces) as it's ID.

(2) When I pass in "ORG-10" (trimmed) I get an entity with "ORG-10"
(trimmed) as it's ID.

Behavior #2 surprised me! I expected "ORG-10   ", with trailing spaces,
just as it is in the database.

As an experiment, I changed my service implementation to use a query on
the key instead of find() and the behavior goes away. That is, I get
"ORG-10   " as the ID of the Organization regardless of whether the
input was trimmed or not.

Am I misunderstanding how it should work?

--Rich

©2008 gg3721.com - Jax Systems, LLC, U.S.A.