Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

NodeType DELETE not possible if TemplateAttributes still associated #130

Open
ahonor opened this issue May 25, 2012 · 4 comments
Open

NodeType DELETE not possible if TemplateAttributes still associated #130

ahonor opened this issue May 25, 2012 · 4 comments

Comments

@ahonor
Copy link
Contributor

ahonor commented May 25, 2012

To reproduce:

Response:

        <h1>Error 500: Internal Server Error</h1>
<dl class="error-details">
<dt>URI</dt><dd>/api/nodeType/none/1</dd>
<dt>Class</dt><dd>org.h2.jdbc.JdbcSQLException</dd><dt>Message</dt><dd>Referential integrity constraint violation: &quot;FKCC31A117448F1C42: PUBLIC.TEMPLATE_ATTRIBUTE FOREIGN KEY(TEMPLATE_ID) REFERENCES PUBLIC.NODE_TYPE(ID)&quot;; SQL statement:
delete from node_type where id=? and version=? [23003-147]</dd></dl><h2>Trace</h2><pre class="stack">   Line | Method
-&gt;&gt; 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   908 | run     in     &#39;&#39;
^   680 | run . . in java.lang.Thread

Caused by ConstraintViolationException: could not delete: [com.dtosolutions.NodeType#1]
-&gt;&gt; 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
@ahonor
Copy link
Contributor Author

ahonor commented May 25, 2012

Actually, it appears it is not possible to delete a NodeType from the GUI as well.

A flash message appears when trying to delete: "NodeType 5 could not be deleted"

Note, this is true even for types that have no Node instances.

@ahonor
Copy link
Contributor Author

ahonor commented May 25, 2012

Further investigation shows that any NodeType that has associated TemplateAttributes cannot be deleted. (i.e., a NodeType w/o associated attributes can be deleted).

@orubel
Copy link
Contributor

orubel commented May 25, 2012

Yes you have to delete associations unless you want an unchecked cascade,... which is dangerous. I can put in more CLEAR error messages if this is what you want but this needs to be specified as to whether the CASCADE DELETE with transactional rollback is wanted or whether CLEARER OUTPUT MESSAGES are or both. At which point this will most likely be all I do today.

@orubel
Copy link
Contributor

orubel commented May 25, 2012

what needs to be done is make sure their is no 'dependson' between node and nodetype so all you have to do is CHECK whether a node nodetype exists in a node or not up front (outside the transaction); this is our main test and needs to happen upfront and outside the transaction as it is easier and doesnt need to happen within transaction since we would never commit this regardless if it existed. Then do a transactional delete through the dependencies (nodetype > templateattribute > templatevalue) and rollback on any fail.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants