Ticket #84 (defect)

Opened 7 years ago

Last modified 5 years ago

event's organizer has "unique" constraint

Status: closed (wontfix)

Reported by: dave@brondsema.net Assigned to: douglm
Priority: major Milestone: Bedework 4.0
Component: core Version:
Keywords: Cc:

I'm not entirely sure of the purpose of the "organizer" field on Event, but it doesn't seem appropriate that it is unique. Especially since via the webadmin add event screen, the organizer field is set as null on new events. And then when attempting to add a second event, the unique constraint fails because there would be two events with the same organizer: "null".

Details: MSSQL. The constraint in question is:

UQ__events__70698DE3
nonclustered, unique, unique key located on PRIMARY	organizerid	

The exception thrown is:

ERROR 2006-06-28 10:49:27,020 org.hibernate.util.JDBCExceptionReporter - Violation of UNIQUE KEY constraint 'UQ__events__70698DE3'. Cannot insert duplicate key in object 'events'.
 DEBUG 2006-06-28 10:49:27,020 org.bedework.calcore.hibernate.CalintfImpl - handleException called
 ERROR 2006-06-28 10:49:27,067 org.bedework.calcore.hibernate.CalintfImpl - org.bedework.calcore.hibernate.HibSession@154fed2
 org.hibernate.exception.ConstraintViolationException: could not insert: [org.bedework.calfacade.BwEventObj]
	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
...

Attachments

Event.hbm.xml.organizer-unique.patch (432 bytes) - added by dave@brondsema.net on 06/28/06 11:14:29.

Change History

06/28/06 11:14:29: Modified by dave@brondsema.net

  • attachment Event.hbm.xml.organizer-unique.patch added.

01/17/07 22:57:44: Modified by douglm

  • milestone set to Bedework 3.3.1.

I don't think this is a bug - it seems to work OK. The unique constraint is to make it a one-to-one relationship as per the hibernate docs.

Recheck this.

02/13/07 10:12:36: Modified by douglm

  • description changed.
  • milestone changed from Bedework 3.3.1 to Bedework 3.3.2.

This turns out to be mssql not adhering to the sql standard which specifies that null != null.

Not that it helps much. The unique constraint effectively turns the mapping into a 1 to 1 relationship and was defined as suggested by the hibernate documentation.

We're going to have to find a way round this if it's going to work on sql-server

The postgres documentation say's

In general, a unique constraint is violated when there are two or more rows in the table where the values of all of the columns included in the constraint are equal. However, null values are not considered equal in this comparison. That means even in the presence of a unique constraint it is possible to store duplicate rows that contain a null value in at least one of the constrained columns. This behavior conforms to the SQL standard, but we have heard that other SQL databases may not follow this rule. So be careful when developing applications that are intended to be portable.

02/22/07 14:01:29: Modified by douglm

  • milestone changed from Bedework 3.3.2 to Bedework 3.3.3.

06/26/07 23:14:38: Modified by douglm

  • milestone changed from Bedework 3.3.3 to Bedework 3.5.

01/29/08 09:40:44: Modified by douglm

  • milestone changed from Bedework 3.5 to Bedework 4.0.

Milestone Bedework 3.5 deleted

02/25/08 00:24:50: Modified by douglm

  • status changed from new to closed.
  • resolution set to wontfix.