Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseWikiWordStoreBuilder.java |
— | — | @@ -259,18 +259,20 @@ |
260 | 260 | */ |
261 | 261 | |
262 | 262 | protected void deleteDataFrom(int rcId, String op, DatabaseTable rel, String field) throws PersistenceException { |
263 | | - deleteDataFrom(rcId, op, rel, field, null, null, null); |
| 263 | + deleteDataFrom(rcId, op, rel, field, null, null, null, false); |
264 | 264 | } |
265 | 265 | |
266 | | - protected void deleteDataFrom(int rcId, String op, DatabaseTable rel, String field, DatabaseTable via, String viaJoinField, String viaField) throws PersistenceException { |
| 266 | + protected void deleteDataFrom(int rcId, String op, DatabaseTable rel, String field, DatabaseTable via, String viaJoinField, String viaField, boolean deleteVia) throws PersistenceException { |
267 | 267 | String sql; |
268 | 268 | |
269 | 269 | if (via!=null) { |
270 | | - sql = "DELETE FROM T"; |
271 | | - sql += " USING "+rel.getSQLName()+" AS T "; |
| 270 | + sql = "DELETE "; |
| 271 | + if (deleteVia) sql += " T, C FROM "; |
| 272 | + else sql += " FROM T USING "; |
| 273 | + sql += rel.getSQLName()+" AS T "; |
272 | 274 | sql += " LEFT JOIN "+via.getSQLName()+" AS C"; |
273 | 275 | sql += " ON T."+field+" = C."+viaJoinField+" "; |
274 | | - sql += " WHERE "+viaField+" "+op+" "+rcId; |
| 276 | + sql += " WHERE C."+viaField+" "+op+" "+rcId; |
275 | 277 | } |
276 | 278 | else { |
277 | 279 | sql = "DELETE FROM "+rel.getSQLName(); |
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java |
— | — | @@ -250,8 +250,7 @@ |
251 | 251 | deleteDataFrom(rcId, op, langlinkTable, "resource"); |
252 | 252 | deleteDataFrom(rcId, op, broaderTable, "resource"); |
253 | 253 | |
254 | | - deleteDataFrom(rcId, op, aboutTable, "resource"); |
255 | | - deleteOrphansFrom(rcId, op, conceptTable, aboutTable, "concept"); |
| 254 | + deleteDataFrom(rcId, op, conceptTable, "id", aboutTable, "concept", "resource", true); |
256 | 255 | |
257 | 256 | deleteDataFrom(rcId, op, aliasTable, "resource"); |
258 | 257 | deleteDataFrom(rcId, op, sectionTable, "resource"); |