https://github.com/fugerit-org/sql-safe-helper
Simple helper to handle update / insert / delete in a SAFE mode
https://github.com/fugerit-org/sql-safe-helper
Last synced: 3 months ago
JSON representation
Simple helper to handle update / insert / delete in a SAFE mode
- Host: GitHub
- URL: https://github.com/fugerit-org/sql-safe-helper
- Owner: fugerit-org
- License: apache-2.0
- Created: 2024-07-16T07:17:18.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-10-10T10:03:20.000Z (9 months ago)
- Last Synced: 2025-02-15T23:43:22.914Z (5 months ago)
- Language: Java
- Size: 51.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# sql-safe-helper
Simple helper to handle update / insert / delete in a SAFE mode.
[](https://github.com/fugerit-org/sql-safe-helper/blob/master/CHANGELOG.md)
[](https://central.sonatype.com/artifact/org.fugerit.java/sql-safe-helper)
[](https://opensource.org/licenses/Apache-2.0)
[](https://github.com/fugerit-org/fj-universe/blob/main/CODE_OF_CONDUCT.md)
[](https://sonarcloud.io/summary/new_code?id=fugerit-org_sql-safe-helper)
[](https://sonarcloud.io/summary/new_code?id=fugerit-org_sql-safe-helper)
[](https://universe.fugerit.org/src/docs/ref/graalvm-ready.html)[](https://universe.fugerit.org/src/docs/versions/java11.html)
[](https://universe.fugerit.org/src/docs/versions/java11.html)
[](https://universe.fugerit.org/src/docs/versions/maven3_9.html)## Quickstart
Add maven dependency :
```xml
org.fugerit.java
sql-safe-helper
${sql-safe-helper-version}
```Sample usage :
```java
try ( Connection conn = ... ) {
String sql = "DELETE FROM sql_safe_test WHERE id = 1";
int expectedUpdateResult = 1;
SqlSafeHelperOutput output = facade.update( conn, expectedUpdateResult, sql );
log.info( "isRollback() : {}", output.isRollback() ); // true if a rollback has been needed
log.info( "updateResult() : {}", output.getValue() ); // update result (se only if no roolback)
log.info( "actualUpdateResult() : {}", output.getActualValue() ); // update result (se even in case of rollback)
}
```When executing the update sql, if the result is different from the expected one,
there will be a rollback for the transaction.