tracker issue : CF-3688668

select a category, or use search below
(searches all categories and all time range)
Title:

Debug information for ORM DDL Update Exceptions occluded by error displayed on screen, even w/robust exceptions enabled

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/CannotReproduce

Reporter/Name(from Bugbase): Adam Tuttle / Adam Tuttle (Adam Tuttle)

Created: 01/02/2014

Components: ORM Support

Versions: 10.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: Final /

Priority/Frequency: Minor / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 0

I made an ORM change and tried to ormReload(). This was the resulting error message:

> Error in executing the DDL.
> 
> Cannot add or update a child row: a foreign key constraint fails (`cased2`.`#sql-504_3f`, CONSTRAINT `FK3737353BFDC35CA7` FOREIGN KEY (`sessionID`) REFERENCES `session` (`sessionID`))

Enabling robust exception information does not improve the messaging AT ALL, except that the Java Stack Trace is shown.

Turning up the Hibernate log level to log DDL changes does show useful information:

> HIBERNATE DEBUG - alter table Document add index FK3737353BFDC35CA7 (sessionID), add constraint FK3737353BFDC35CA7 foreign key (sessionID) references `Session` (sessionID)

Clearly it's trying to resolve data that exists in the database that violates a constraint that's being created, so constraint creation fails.

The failure here is to report useful information in the exception message. I originally spent some time digging into my database looking for a constraint with id "FK3737353BFDC35CA7" but obviously couldn't find it because it couldn't be created. A wild goose chase!

I recall you have asked us to let you know how ORM Error Reporting could be improved, so here you go! Bubble these error messages up to the surface when robust exception information is enabled! Having to go tweak logging settings and then dig around in logs is NOT germane to debugging CFML.

I'm logging this against CF10 since that's the latest, but obviously it also affects CF9.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3688668

External Customer Info:
External Company:  
External Customer Name: Adam Tuttle
External Customer Email:  
External Test Config: My Hardware and Environment details: N/A

Attachments:

Comments:

There could be two possibilities here. Either the constraint couldn't be created or the data could not be inserted because of existing constraint. Your error suggests that its the later but you say you didn't find the constraint at all. In cases where the constraint could not be created the error should look like [macromedia][SQLServer JDBC Driver][SQLServer]ALTER TABLE statement conflicted with COLUMN FOREIGN KEY constraint 'FKC42BD1642EFFE958'. The conflict occurred in database 'TestDB', table 'categories', column 'CategoryID'. So iam confused here. Could you send your code so we can investigate?
Comment by Himavanth R.
13767 | May 09, 2014 04:34:35 AM GMT
No. If you had triaged this bug 4 months ago when I submitted it then I might have been able to provide code at the time. As I noted 4 months ago, I've already worked around the issue; and at the time I provided what I (still) believe to be a really well written bug report. With the benefit of hindsight I suppose I should have included the ORM code change that I was attempting to make (before/after), but I did provide detailed error messages and a good explanation of what was going on at the time. I'm no longer working on this app, and haven't got a clue what specific change I was making at the time. I am dubious of the error message that you propose _should_ have displayed in the case that I described, because you're proposing an SQL error where clearly I am using ORM/Hibernate. I don't recall ever seeing SQL errors like the one you propose come out of Hibernate. But here, let me do your job for you: Based on the proper error message that I dug out of the Hibernate logs, it would appear that I'm attempting to add a relationship to an existing entity. There would appear to have been data in the table already; and this new relationship enforced not-null. Thus, when attempting to add the foreign key relationship, the constraint creation failed because the existing data would have null values. Apologies for the hostility, I suppose, but you really should not need my help to come up with that.
Comment by External U.
13768 | May 09, 2014 07:08:23 AM GMT
We are not able to reproduce this issue and hence closing this bug.
Comment by Nimit S.
13769 | September 22, 2015 03:10:18 AM GMT