Skip to content

Commit 6f2df02

Browse files
committed
Add pre save/delete handlers
1 parent 77d6011 commit 6f2df02

File tree

7 files changed

+6
-1
lines changed

7 files changed

+6
-1
lines changed

memory

0 Bytes
Binary file not shown.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.craftmend</groupId>
88
<artifactId>storm</artifactId>
9-
<version>1.2.3</version>
9+
<version>1.2.4</version>
1010

1111
<properties>
1212
<maven.compiler.source>1.8</maven.compiler.source>

src/main/java/com/craftmend/storm/Storm.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ public <T extends StormModel> CompletableFuture<Collection<T>> findAll(Class<T>
233233
*/
234234
public void delete(StormModel model) throws SQLException {
235235
catchState();
236+
model.preDelete();
236237
ModelParser parser = registeredModels.get(model.getClass());
237238
if (parser == null) throw new IllegalArgumentException("The model " + model.getClass().getName() + " isn't loaded. Please call storm.migrate() with an empty instance");
238239
if (model.getId() == null) throw new IllegalArgumentException("This model doesn't have an ID");
@@ -264,6 +265,7 @@ public <T extends StormModel> ModelParser<T> getParsedModel(Class<T> m, boolean
264265
*/
265266
public int save(StormModel model) throws SQLException {
266267
catchState();
268+
model.preSave();
267269
String updateOrInsert = "update %tableName set %psUpdateValues where id=%id";
268270
String insertStatement = "insert into %tableName(%insertVars) values(%insertValues);";
269271

src/main/java/com/craftmend/storm/api/StormModel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@ public StatementBuilder statements() {
3636
return statementBuilder;
3737
}
3838

39+
public void preSave() {}
40+
public void preDelete() {}
41+
3942
}

test-data/mass-test.db

464 KB
Binary file not shown.

test-data/mass-test.db-journal

-512 Bytes
Binary file not shown.

test-data/relation-test.db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)