Skip to content

Commit 8111fcf

Browse files
authored
Feature/storm 21 (#22)
* Refactor interceptors to ScopedValues.
1 parent 4bfa83c commit 8111fcf

31 files changed

Lines changed: 782 additions & 765 deletions

File tree

README.adoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ Maven::
4545
<dependency>
4646
<groupId>st.orm</groupId>
4747
<artifactId>storm</artifactId>
48-
<version>1.3.2</version>
48+
<version>1.3.3</version>
4949
<scope>compile</scope>
5050
</dependency>
5151
----
5252
Gradle::
5353
+
5454
[source,groovy]
5555
----
56-
implementation 'st.orm:storm:1.3.2'
56+
implementation 'st.orm:storm:1.3.3'
5757
----
5858
====
5959

@@ -846,15 +846,15 @@ Maven::
846846
<dependency>
847847
<groupId>st.orm</groupId>
848848
<artifactId>storm-oracle</artifactId>
849-
<version>1.3.2</version>
849+
<version>1.3.3</version>
850850
<scope>runtime</scope>
851851
</dependency>
852852
----
853853
Gradle::
854854
+
855855
[source,groovy]
856856
----
857-
runtimeOnly 'st.orm:storm-oracle:1.3.2'
857+
runtimeOnly 'st.orm:storm-oracle:1.3.3'
858858
----
859859
====
860860

@@ -876,15 +876,15 @@ Maven::
876876
<dependency>
877877
<groupId>st.orm</groupId>
878878
<artifactId>storm-metamodel-processor</artifactId>
879-
<version>1.3.2</version>
879+
<version>1.3.3</version>
880880
<scope>provided</scope>
881881
</dependency>
882882
----
883883
Gradle::
884884
+
885885
[source,groovy]
886886
----
887-
annotationProcessor 'st.orm:storm-metamodel-processor:1.3.2'
887+
annotationProcessor 'st.orm:storm-metamodel-processor:1.3.3'
888888
----
889889
====
890890

@@ -952,15 +952,15 @@ Maven::
952952
<dependency>
953953
<groupId>st.orm</groupId>
954954
<artifactId>storm-json</artifactId>
955-
<version>1.3.2</version>
955+
<version>1.3.3</version>
956956
<scope>compile</scope>
957957
</dependency>
958958
----
959959
Gradle::
960960
+
961961
[source,groovy]
962962
----
963-
implementation 'st.orm:storm-json:1.3.2'
963+
implementation 'st.orm:storm-json:1.3.3'
964964
----
965965
====
966966

@@ -1039,15 +1039,15 @@ Maven::
10391039
<dependency>
10401040
<groupId>st.orm</groupId>
10411041
<artifactId>storm-spring</artifactId>
1042-
<version>1.3.2</version>
1042+
<version>1.3.3</version>
10431043
<scope>compile</scope>
10441044
</dependency>
10451045
----
10461046
Gradle::
10471047
+
10481048
[source,groovy]
10491049
----
1050-
implementation 'st.orm:storm-spring:1.3.2'
1050+
implementation 'st.orm:storm-spring:1.3.3'
10511051
----
10521052
====
10531053

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</properties>
1313
<groupId>st.orm</groupId>
1414
<artifactId>storm-framework</artifactId>
15-
<version>1.3.2</version>
15+
<version>1.3.3</version>
1616
<packaging>pom</packaging>
1717
<name>Storm Framework</name>
1818
<description>A SQL Template and ORM framework, focusing on modernizing and simplifying database programming.</description>

storm-json/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>st.orm</groupId>
88
<artifactId>storm-framework</artifactId>
9-
<version>1.3.2</version>
9+
<version>1.3.3</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212
<artifactId>storm-json</artifactId>

storm-json/src/test/java/st/orm/json/JsonIntegrationTest.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import static org.junit.jupiter.api.Assertions.assertTrue;
3535
import static st.orm.Templates.ORM;
3636
import static st.orm.Templates.alias;
37-
import static st.orm.template.SqlInterceptor.consume;
37+
import static st.orm.template.SqlInterceptor.observe;
3838

3939
@ExtendWith(SpringExtension.class)
4040
@ContextConfiguration(classes = IntegrationConfig.class)
@@ -175,16 +175,18 @@ SELECT v.id, v.first_name, v.last_name, JSON_OBJECTAGG(s.id, s.name)
175175
INNER JOIN vet_specialty vs ON vs.vet_id = v.id
176176
INNER JOIN specialty s ON s.id = vs.specialty_id
177177
GROUP BY v.id""";
178-
try (var _ = consume(sql -> assertEquals(expectedSql, sql.statement()))) {
179-
ORM(dataSource).selectFrom(Vet.class, SpecialtyNamesByVet.class, RAW."""
180-
\{Vet.class}, JSON_OBJECTAGG(\{Specialty.class})""")
181-
.innerJoin(VetSpecialty.class).on(Vet.class)
182-
.innerJoin(Specialty.class).on(VetSpecialty.class)
183-
.append(RAW."GROUP BY \{Vet.class}.id")
184-
.getResultList();
185-
} catch (PersistenceException _) {
186-
// H2 Does not support JSON_OBJECTAGG. We only check the expected SQL.
187-
}
178+
observe(sql -> assertEquals(expectedSql, sql.statement()), () -> {
179+
try {
180+
ORM(dataSource).selectFrom(Vet.class, SpecialtyNamesByVet.class, RAW."""
181+
\{Vet.class}, JSON_OBJECTAGG(\{Specialty.class})""")
182+
.innerJoin(VetSpecialty.class).on(Vet.class)
183+
.innerJoin(Specialty.class).on(VetSpecialty.class)
184+
.append(RAW."GROUP BY \{Vet.class}.id")
185+
.getResultList();
186+
} catch (PersistenceException _) {
187+
// H2 Does not support JSON_OBJECTAGG. We only check the expected SQL.
188+
}
189+
});
188190
}
189191

190192
// No need to specify the sub types here, as we're automatically registering the implementations of the sealed interface.

storm-kotlin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>st.orm</groupId>
88
<artifactId>storm-framework</artifactId>
9-
<version>1.3.2</version>
9+
<version>1.3.3</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212
<artifactId>storm-kotlin</artifactId>

storm-kotlin/src/main/java/st/orm/kotlin/template/impl/KORMTemplateImpl.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.lang.reflect.InvocationTargetException;
3636
import java.lang.reflect.ParameterizedType;
3737
import java.lang.reflect.Type;
38-
import java.sql.SQLException;
3938
import java.util.HashSet;
4039
import java.util.Optional;
4140
import java.util.Set;
@@ -44,7 +43,7 @@
4443
import static java.lang.System.identityHashCode;
4544
import static java.lang.reflect.Proxy.newProxyInstance;
4645
import static java.util.Optional.empty;
47-
import static st.orm.template.SqlInterceptor.consume;
46+
import static st.orm.template.SqlInterceptor.observeThrowing;
4847

4948
public final class KORMTemplateImpl extends KQueryTemplateImpl implements KORMTemplate {
5049
private final static ORMReflection REFLECTION = Providers.getORMReflection();
@@ -183,18 +182,20 @@ private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> interfacesFou
183182
private <T extends KRepository> T wrapRepository(@Nonnull T repository) {
184183
return (T) newProxyInstance(repository.getClass().getClassLoader(), getAllInterfaces(repository.getClass()).toArray(new Class[0]), (_, method, args) -> {
185184
var lastSql = new AtomicReference<Sql>();
186-
try (var _ = consume(lastSql::setPlain)) {
187-
try {
188-
return method.invoke(repository, args);
189-
} catch (Exception | Error e) {
190-
throw e;
191-
} catch (Throwable e) {
192-
throw new PersistenceException(e);
193-
}
185+
try {
186+
return observeThrowing(lastSql::setPlain, () -> {
187+
try {
188+
return method.invoke(repository, args);
189+
} catch (Exception | Error e) {
190+
throw e;
191+
} catch (Throwable e) {
192+
throw new PersistenceException(e);
193+
}
194+
});
194195
} catch (InvocationTargetException e) {
195196
try {
196197
throw e.getTargetException();
197-
} catch (SQLException | PersistenceException ex) {
198+
} catch (Exception ex) {
198199
Sql sql = lastSql.getPlain();
199200
if (sql != null && ex.getSuppressed().length == 0) {
200201
ex.addSuppressed(new SqlTemplateException(STR."""

storm-mariadb/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>st.orm</groupId>
88
<artifactId>storm-framework</artifactId>
9-
<version>1.3.2</version>
9+
<version>1.3.3</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212
<artifactId>storm-mariadb</artifactId>

0 commit comments

Comments
 (0)