11package com .eternalcode .parcellockers .database .wrapper ;
22
33import com .eternalcode .commons .scheduler .Scheduler ;
4+ import com .eternalcode .parcellockers .ParcelLockers ;
45import com .eternalcode .parcellockers .database .DatabaseManager ;
56import com .j256 .ormlite .dao .Dao ;
67import panda .std .function .ThrowingFunction ;
@@ -21,34 +22,56 @@ protected AbstractRepositoryOrmLite(DatabaseManager databaseManager, Scheduler s
2122 }
2223
2324 protected <T > CompletableFuture <Dao .CreateOrUpdateStatus > save (Class <T > type , T entity ) {
24- return this .action (type , dao -> dao .createOrUpdate (entity ));
25+ return this .action (type , dao -> {
26+ ParcelLockers .DEBUG_LOGGER .info ("Saving entity: {}" , entity );
27+ return dao .createOrUpdate (entity );
28+ });
2529 }
2630
2731 protected <T > CompletableFuture <T > saveIfNotExist (Class <T > type , T entity ) {
28- return this .action (type , dao -> dao .createIfNotExists (entity ));
32+ return this .action (type , dao -> {
33+ ParcelLockers .DEBUG_LOGGER .info ("Saving entity (IF NOT EXIST mode): {}" , entity );
34+ return dao .createIfNotExists (entity );
35+ });
2936 }
3037
3138 protected <T , ID > CompletableFuture <T > select (Class <T > type , ID id ) {
32- return this .action (type , dao -> dao .queryForId (id ));
39+ return this .action (type , dao -> {
40+ ParcelLockers .DEBUG_LOGGER .info ("Selecting: {}" , id );
41+ return dao .queryForId (id );
42+ });
3343 }
3444
3545 protected <T , ID > CompletableFuture <Optional <T >> selectSafe (Class <T > type , ID id ) {
36- return this .action (type , dao -> Optional .ofNullable (dao .queryForId (id )));
46+ return this .action (type , dao -> {
47+ ParcelLockers .DEBUG_LOGGER .info ("Selecting (safe mode): {}" , id );
48+ return Optional .ofNullable (dao .queryForId (id ));
49+ });
3750 }
3851
3952 protected <T > CompletableFuture <Integer > delete (Class <T > type , T entity ) {
40- return this .action (type , dao -> dao .delete (entity ));
53+ return this .action (type , dao -> {
54+ ParcelLockers .DEBUG_LOGGER .info ("Deleting: {}" , entity );
55+ return dao .delete (entity );
56+ });
4157 }
4258
4359 protected <T > CompletableFuture <Integer > deleteAll (Class <T > type ) {
44- return this .action (type , dao -> dao .deleteBuilder ().delete ());
60+ return this .action (type , dao -> {
61+ ParcelLockers .DEBUG_LOGGER .info ("Deleting all entities of type: {}" , type .getSimpleName ());
62+ return dao .deleteBuilder ().delete ();
63+ });
4564 }
4665
4766 protected <T , ID > CompletableFuture <Integer > deleteById (Class <T > type , ID id ) {
48- return this .action (type , dao -> dao .deleteById (id ));
67+ return this .action (type , dao -> {
68+ ParcelLockers .DEBUG_LOGGER .info ("Deleting: {}" , id );
69+ return dao .deleteById (id );
70+ });
4971 }
5072
5173 protected <T > CompletableFuture <List <T >> selectAll (Class <T > type ) {
74+ ParcelLockers .DEBUG_LOGGER .info ("Selecting all entities of type: {}" , type .getSimpleName ());
5275 return this .action (type , Dao ::queryForAll );
5376 }
5477
0 commit comments