db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: unique columns must be nullable ?
Date Wed, 13 Dec 2006 03:26:32 GMT

On Dec 12, 2006, at 6:42 PM, Randy Letness wrote:

> Mike Matrigali wrote:
>> Out of curiousity what behavior does Hibernate expect when 2 nulls  
>> are inserted into a "unique" nullable column?
>>
>>
>
> When you specify a unique constraint in hibernate, I'm pretty sure  
> its only used by the schema export tools to generate a unique  
> constraint when generating the DDL statements.  That is, it doesn't  
> care if you insert 2 nulls, it relies on the database to throw an  
> exception.

That's my understanding as well. If it's mapped to a toOne  
relationship, Hibernate expects that the database will not offer two  
rows to populate one relationship, but aside from that, it won't much  
care.

On the outbound side, Hibernate might try to insert the second row  
with the same value if that's what the object model calls for, and  
expect the database to throw an exception.

> Things break when hibernate tries to generate a unique constraint  
> on nullable columns in Derby.  I guess its not smart enough to  
> realize Derby (or any other db) doesn't support this.

Hibernate does have database personality modules to reflect this kind  
of stuff. There might be a bug. It's probably worthwhile to make sure  
you have the latest code and if it still fails, a Hibernate forum  
question would probably result in at least a semi-official response.  
Hibernate is open source, and would probably be open to a patch if  
there is an issue.

Craig

> I have run into the same problem as I am working on a project that  
> supports both MySQL and Derby and MySQL supports constraints on  
> nullable columns, while Derby doesn't.
>
> -Randy

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Mime
View raw message