How to globally set unique contraints to allow NULL values?

449 views
Skip to first unread message

M. Walter

unread,
Mar 15, 2012, 5:18:22 AM3/15/12
to h2-da...@googlegroups.com
H2 does not allow NULL values in unique constraints. Oracle does.
Is there a property or another way to set unique constraints to allow NULL values globally?

Something like SET_UNIQUE_CONSTRAINTS_TO_ALLOW_NULL_VALUE=TRUE?

Thanks for your help!

M. Walter

unread,
Mar 19, 2012, 4:25:35 AM3/19/12
to h2-da...@googlegroups.com
No idea? Anybody? :-(

We use H2 for unit tests. The constraints are defined on the JPA entities. While Oracle allows NULL values for contraint fields, H2 initialises strings with "", integers with 0 and so on per default. How can I change this behaviour?

Noel Grandin

unread,
Mar 19, 2012, 4:28:49 AM3/19/12
to h2-da...@googlegroups.com, M. Walter
It looks like we currently don't support that feature.

Patches are welcome :-)

> How can I change this behaviour? --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/chcnhEyIzOgJ.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.

M. Walter

unread,
Mar 19, 2012, 4:45:45 AM3/19/12
to h2-da...@googlegroups.com, M. Walter
Okay, so do I have to create a JIRA ticket or something like that to get the feature?

Noel Grandin

unread,
Mar 19, 2012, 4:51:09 AM3/19/12
to h2-da...@googlegroups.com, M. Walter
You're welcome to log a feature request at code.google.com/h/h2database
But we're all pretty busy right now, so feature requests are a little
priority.

On 2012-03-19 10:45, M. Walter wrote:
> Okay, so do I have to create a JIRA ticket or something like that to
> get the feature?

> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit

> https://groups.google.com/d/msg/h2-database/-/xIbvH8mgWOYJ.

M. Walter

unread,
Mar 19, 2012, 5:11:42 AM3/19/12
to h2-da...@googlegroups.com, M. Walter

Thomas Mueller

unread,
Mar 21, 2012, 1:59:32 AM3/21/12
to h2-da...@googlegroups.com
Hi,

H2 already supports NULL in unique constraints.

Could you provide a simple test case with SQL statements (create table, insert,...)? Please not a JPA test case, just some SQL. It might be a problem with the JPA configuration you are using.

Regards,
Thomas



On Monday, March 19, 2012, M. Walter wrote:
Okay done: http://code.google.com/p/h2database/issues/detail?id=385

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/yzG5EDlG8CoJ.
Reply all
Reply to author
Forward
0 new messages