the tables structure_data, mol_data, and svg_data are not correctly handled on dataset and tree deletion. The tree deletion causes the scaffold_data to be cleand and the dataset deletion causes molecule_data to be cleaned. However, molecules and scaffolds have a common superclass which cannot be cascaded by a foreign key constraint (it is ambigious). Therefore, we will need a solution to clean the super class as well.
this may be solvable using interceptors
https://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#events
Unfortunately, if a tree is deleted, the Interceptor is only triggered for the tree but not for the contained scaffolds. I think the interceptor only works, when an object is deleted directly by the hibernate-framework, but not if it is deleted implicitely by the database.
However the interceptor can be used to do the necessary cleanup when a tree is deleted.
Implemented this behaviour ([6512af]). Cleanup for datasets is still missing.
Related
Commit: [6512af]
The query did not work for datasets. Some foreign key constraints caused trouble. Updated the queries so the structure_data table is cleaned before the respective svg_data and mol_data-entries are removed ([1ee13d]).
Related
Commit: [1ee13d]
looks good on mysql, but fails on hsql with the exception
org.hibernate.exception.SQLGrammarException: could not prepare statement
.This is most likely a problem of different SQL-dialects. HQL would be the better alternative to SQL here, since it abstracts database specific SQL dialects. Please evaluate my first guess and rewrite the statements in HQL. This will also allow us to easily port the backend to new database types in the feature.
MYSQL tested by counting the elements int the tables:
Using HQL solved the problem ([2416e7]). Nice side-effect: The code becomes much shorter. Also it is not necessary to explicitely access the structure table. HQL automatically also deletes the entries of the super-class in the respective table. However mol_data and svg_data must still be cleaned manually.
Also added a worker and a progress dialog for tree deletion since this process takes more time now ([c59042]).
Related
Commit: [2416e7]
Commit: [c59042]
Does not delete mol_data and svg_data, when deleting a tree (tested with mysql). Furthermore,it seems that
strucQuery.executeUpdate();
in line 62 of DeleteInterceptor can be deleted, since the other strucQuery is updated outsite the if. Plus one minor thing, please useelse if
in line 64.This is a bit strange. Added a test-query to get SVG entries that are not referenced by a structure any longer:
It returns the correct number of orphaned svgs. But running the delete query what looks nearly the same
returns always 0 items deleted, until the last dataset is deleted, then it clears the table completely.
By chance i found the solution. In HQL DELETE queries no joins are allowed. In the previous implementation the structure table was joined with the svg table or the mol table respectively in the sub query. By replacing WHERE NOT EXISTS with WHERE NOT IN, the sub query does not need a join any longer ([450f0f]).
Related
Commit: [450f0f]
Last edit: Philipp Mewes 2018-04-13
merged in [381d4d]
Related
Commit: [381d4d]