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 11:22 Go to next message
Alex is currently offline AlexFriend
Messages: 2
Registered: June 2010
Junior Member

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?


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

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: 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,
Previous Topic:Problem on EclipseLink JPA Weaving using Toplink session.xml, project.xml as JPA Source
Next Topic:Select count(*)
Goto Forum:

Current Time: Sun Dec 17 08:16:42 GMT 2017

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

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