Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EL 1.2 / Oracle10: Empty String automatically converted to a Whitespace
EL 1.2 / Oracle10: Empty String automatically converted to a Whitespace [message #506466] Thu, 07 January 2010 11:04 Go to next message
Hans Harz is currently offline Hans HarzFriend
Messages: 20
Registered: July 2009
Junior Member
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 #506964 is a reply to message #506466] Mon, 11 January 2010 14:51 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

EclipseLink does not do anything like this, unless you have done some specific customization to make it do this in an event or such.

My guess would be it is your JDBC driver.

If you enable logging in EclipseLink what is included in the EclipseLink SQL log, " " or ""?


James : Wiki : Book : Blog : Twitter
Re: EL 1.2 / Oracle10: Empty String automatically converted to a Whitespace [message #507037 is a reply to message #506964] Mon, 11 January 2010 18:27 Go to previous message
Hans Harz is currently offline Hans HarzFriend
Messages: 20
Registered: July 2009
Junior Member
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 ''
Previous Topic:sequence getting out of sync summary
Next Topic:CLOB lenght problme on different databases
Goto Forum:
  


Current Time: Tue Mar 19 08:35:35 GMT 2024

Powered by FUDForum. Page generated in 0.02776 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top