Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Storing empty strings in an oracle database
Storing empty strings in an oracle database [message #538322] Mon, 07 June 2010 07:22 Go to next message
Alex is currently offline Alex
Messages: 2
Registered: June 2010
Junior Member
Hi,

I've a question how to handle empty strings and NULL for "String" columns in a oracle database.

I know Oracle treats an empty string as NULL and therefore a column definition with nullable=false will cause a rollback on inserts with an empty string as value.

The only workaround I've found is to use a "special character" to mark an empty string.

I want to support more than one database system, not only oracle.
I use EclipseLink 1.1.3

Are there any other solutions?

thanks!

Re: Storing empty strings in an oracle database [message #538413 is a reply to message #538322] Mon, 07 June 2010 11:31 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1016
Registered: July 2009
Senior Member
Hello,

Oracle treats an empty string for Varchar2 columns as null. You could use a char type instead, but I'm not sure why you are using a not-null constraint on a field that seems to require allowing empty data. Wouldn't allowing null work? EclipseLink is able to convert nulls it reads from the database into a default value via the setNullValue api on DatabaseMapping, as described at: http://wiki.eclipse.org/Configuring_a_Mapping_%28ELUG%29#Con figuring_a_Default_Null_Value_at_the_Mapping_Level

Unfortunately I do not know if this is available from annotations, so you may need to use a customizer to get the mapping.

Best Regards,
Chris
Previous Topic:unable to get lazy loading to work
Next Topic:Query across Variable One to One mapping
Goto Forum:
  


Current Time: Wed Jul 23 02:02:34 EDT 2014

Powered by FUDForum. Page generated in 0.02661 seconds