EL 1.2 / Oracle10: Empty String automatically converted to a Whitespace [message #506466] |
Thu, 07 January 2010 06:04  |
Eclipse User |
|
|
|
Hi all,
EL 1.2 seems to convert an empty string to a whitespace string automatically.
Our system is working on different db-backends and we had some problems with empty strings in not null columns on oracle DBs in the past. I don't want to start this discussion again, I'm fine with the Oracle behavior.
But now I noticed something very strange.
1. I create a simple object and set the name to an empty string
2. I persist this object.
3. A log statement in OnPersist writes out the empty string as name
4. then I see this in the log: PreparedStatement.setString(5, " "). Please note the Whitespace.
5. and yes in the oracle database there is whitespace in the name column.
6. I load the object again from the database and make a assert on the name. That lead to a failing test:
org.junit.ComparisonFailure: expected: <[]> but was:<[ ]>
Is this a known behavior? If yes, with which version of EL it was introduced?
regards,
Hans
|
|
|
|
Re: EL 1.2 / Oracle10: Empty String automatically converted to a Whitespace [message #507037 is a reply to message #506964] |
Mon, 11 January 2010 13:27  |
Eclipse User |
|
|
|
Hi James,
thank you for your answer. I don't think that it is the JDBC driver.
The Value column is a not null CLOB value. I think that first a "dummy" value is inserted, and afterwards the real value should be inserted with a select for update.
Again, I would expect a exception, because I entered '' in a not null column.
Here is a detailed log:
PersistenceLayer_Terminology - on Persist UserSetting testuser with value ''
assign sequence to the object (152 -> ...UserSettingEjb@8395b17d)
begin unit of work commit
begin transaction
Execute query InsertObjectQuery(...UserSettingEjb@8395b17d)
NSERT INTO USERSETTINGEJB (ID, USERID, EXPLICITVERSION, name, VALUE, UUID, EXTERNAL_ID, VERSION) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
bind => [152, testuser, 2, foo, , 7ae939c7-1fab-46e8-a156-29c5b9e07223, 1263232915794, 1]
SELECT VALUE FROM USERSETTINGEJB WHERE (ID = ?) FOR UPDATE
bind => [152]
Writing CLOB value(size = 1 bytes) through the locator to the table field: VALUE
PersistenceLayer_Terminology - onPostPersist UserSetting testuser with value ''
|
|
|
Powered by
FUDForum. Page generated in 0.04571 seconds