Bug 103022 - Using DataQuery.next() in ObservableDomainObject.beforeDelete()
Summary: Using DataQuery.next() in ObservableDomainObject.beforeDelete()
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Web Application Framework
Classification: Retired
Component: persistence
Version: nightly
Hardware: All
OS: Linux
medium
high
Target Milestone: ---
Assignee: Archit Shah
QA Contact: Jon Orris
URL:
Whiteboard:
Depends On:
Blocks: 100952
TreeView+ depends on / blocked
 
Reported: 2003-08-25 16:06 UTC by Carsten Clasohm
Modified: 2007-04-18 16:57 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2003-12-09 23:35:39 UTC
Embargoed:


Attachments (Terms of Use)

Description Carsten Clasohm 2003-08-25 16:06:31 UTC
Description of problem:
I have overridden ObservableDomainObject.beforeDelete() in ContentItem to delete
objects which reference the to-be-deleted content item. To find these objects, I
use a DataQuery. When I call its next() method, the Cursor.next() method calls
Session.flush(), which tries to delete the content item, which fails with a
"ORA-02292: integrity constraint violated" error.


Version-Release number of selected component (if applicable):
6.0

How reproducible:
Always

Steps to Reproduce:
1. Define a table with a referential constraint on cms_items, and insert a row
for an existing content item.

2. Define ContentItem.beforeDelete(), create some DataQuery, and call next().
Don't worry about actually finding or deleting the offending rows - any
DataQuery should work.

3. Use the CMS UI to delete the ContentItem. You will get an exception on the
line where next() is called in beforeDelete().


Actual Results:  The stack trace:

2003-08-25 17:50:33,072 [002-0] ERROR rdbms.RDBMSEngine - delete from cms_items
where cms_items.item_id = ?
java.sql.SQLException: ORA-02292: integrity constraint
(FTVICC.CMS_LINKS_TARGET_ITEM_F_L_FW5) violated - child record found

	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
	at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:2321)
	at oracle.jdbc.oci8.OCIDBAccess.executeFetch(OCIDBAccess.java:1741)
	at oracle.jdbc.oci8.OCIDBAccess.parseExecuteFetch(OCIDBAccess.java:1902)
	at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
	at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
	at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
	at
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
	at
oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:656)
	at com.arsdigita.db.PreparedStatement.doExecute(PreparedStatement.java:213)
	at com.arsdigita.db.PreparedStatement.execute(PreparedStatement.java:184)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.java:442)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.execute(RDBMSEngine.java:394)
	at com.redhat.persistence.engine.rdbms.RDBMSEngine.flush(RDBMSEngine.java:361)
	at com.redhat.persistence.Session.flushInternal(Session.java:552)
	at com.redhat.persistence.Session.flush(Session.java:497)
	at com.redhat.persistence.Cursor.next(Cursor.java:108)
	at com.arsdigita.persistence.DataQueryImpl.next(DataQueryImpl.java:456)
	at com.arsdigita.cms.ContentItem.beforeDelete(ContentItem.java:437)
	at
com.arsdigita.domain.DomainObject$SaveObserver.beforeDelete(DomainObject.java:619)
	at com.arsdigita.persistence.BeforeDeleteEvent.doInvoke(DataEvent.java:202)
	at com.arsdigita.persistence.DataEvent.invoke(DataEvent.java:39)
	at com.arsdigita.persistence.DataObjectImpl.fireObserver(DataObjectImpl.java:476)
	at com.arsdigita.persistence.DataEvent.fire(DataEvent.java:48)
	at com.arsdigita.persistence.Session$FlushEventProcessor.flush(Session.java:343)
	at com.redhat.persistence.Session.flushInternal(Session.java:532)
	at com.redhat.persistence.Session.flush(Session.java:497)
	at com.arsdigita.persistence.DataObjectImpl.delete(DataObjectImpl.java:356)
	at com.arsdigita.domain.DomainObject.delete(DomainObject.java:324)
	at
com.arsdigita.cms.ui.folder.FolderBrowser$ItemDeleter.cellSelected(FolderBrowser.java:335)


Expected Results:  I expect beforeDelete() to be called *before* the item is
deleted. At the very least, I have to be able to use a DataQuery in beforeDelete().

Comment 1 Carsten Clasohm 2003-08-25 16:08:36 UTC
This problem occurs for FTVI, where we use the link checking code from DP WMCS.
Link objects are automatically created for published content items, and this bug
makes it impossible to delete content items for which such Link objects exist.
Fixing this is pretty urgent for the client.


Comment 2 Archit Shah 2003-08-25 16:44:41 UTC
This bug is a high priority. I started working on it last week. I expect to have
it done this week.

Comment 3 Archit Shah 2003-09-10 15:11:02 UTC
A candidate fix has been applied to the tip (@35834). Please test it. It merges
cleanly to 6.0 branch, but I'm not going to commit there until the fix has
stabilized.

Comment 4 Scott Seago 2003-09-10 15:33:07 UTC
Preliminary test was successful. I'm performing a very similar operation on the
rickshaw codebase: upon deleting a contentItem, clearing the targetItem
association in any link which points to the to-be-deleted ContentItem. With this
changelist, beforeDelete performs as expected (although it would be nice for
persistence to be able to automatically clear associations when the target of a
one-way association is deleted), removing the need for this beforeDelete method
entirely.

Comment 5 Archit Shah 2003-09-16 21:34:17 UTC
applied to 6.0 branch (@36022)

Comment 6 Carsten Clasohm 2003-10-10 14:52:46 UTC
That fixed our problem.



Note You need to log in before you can comment on or make changes to this bug.