Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ Maven::
<dependency>
<groupId>st.orm</groupId>
<artifactId>storm</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<scope>compile</scope>
</dependency>
----
Gradle::
+
[source,groovy]
----
implementation 'st.orm:storm:1.3.2'
implementation 'st.orm:storm:1.3.3'
----
====

Expand Down Expand Up @@ -846,15 +846,15 @@ Maven::
<dependency>
<groupId>st.orm</groupId>
<artifactId>storm-oracle</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<scope>runtime</scope>
</dependency>
----
Gradle::
+
[source,groovy]
----
runtimeOnly 'st.orm:storm-oracle:1.3.2'
runtimeOnly 'st.orm:storm-oracle:1.3.3'
----
====

Expand All @@ -876,15 +876,15 @@ Maven::
<dependency>
<groupId>st.orm</groupId>
<artifactId>storm-metamodel-processor</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<scope>provided</scope>
</dependency>
----
Gradle::
+
[source,groovy]
----
annotationProcessor 'st.orm:storm-metamodel-processor:1.3.2'
annotationProcessor 'st.orm:storm-metamodel-processor:1.3.3'
----
====

Expand Down Expand Up @@ -952,15 +952,15 @@ Maven::
<dependency>
<groupId>st.orm</groupId>
<artifactId>storm-json</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<scope>compile</scope>
</dependency>
----
Gradle::
+
[source,groovy]
----
implementation 'st.orm:storm-json:1.3.2'
implementation 'st.orm:storm-json:1.3.3'
----
====

Expand Down Expand Up @@ -1039,15 +1039,15 @@ Maven::
<dependency>
<groupId>st.orm</groupId>
<artifactId>storm-spring</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<scope>compile</scope>
</dependency>
----
Gradle::
+
[source,groovy]
----
implementation 'st.orm:storm-spring:1.3.2'
implementation 'st.orm:storm-spring:1.3.3'
----
====

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</properties>
<groupId>st.orm</groupId>
<artifactId>storm-framework</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<packaging>pom</packaging>
<name>Storm Framework</name>
<description>A SQL Template and ORM framework, focusing on modernizing and simplifying database programming.</description>
Expand Down
2 changes: 1 addition & 1 deletion storm-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>st.orm</groupId>
<artifactId>storm-framework</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>storm-json</artifactId>
Expand Down
24 changes: 13 additions & 11 deletions storm-json/src/test/java/st/orm/json/JsonIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static st.orm.Templates.ORM;
import static st.orm.Templates.alias;
import static st.orm.template.SqlInterceptor.consume;
import static st.orm.template.SqlInterceptor.observe;

@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = IntegrationConfig.class)
Expand Down Expand Up @@ -175,16 +175,18 @@ SELECT v.id, v.first_name, v.last_name, JSON_OBJECTAGG(s.id, s.name)
INNER JOIN vet_specialty vs ON vs.vet_id = v.id
INNER JOIN specialty s ON s.id = vs.specialty_id
GROUP BY v.id""";
try (var _ = consume(sql -> assertEquals(expectedSql, sql.statement()))) {
ORM(dataSource).selectFrom(Vet.class, SpecialtyNamesByVet.class, RAW."""
\{Vet.class}, JSON_OBJECTAGG(\{Specialty.class})""")
.innerJoin(VetSpecialty.class).on(Vet.class)
.innerJoin(Specialty.class).on(VetSpecialty.class)
.append(RAW."GROUP BY \{Vet.class}.id")
.getResultList();
} catch (PersistenceException _) {
// H2 Does not support JSON_OBJECTAGG. We only check the expected SQL.
}
observe(sql -> assertEquals(expectedSql, sql.statement()), () -> {
try {
ORM(dataSource).selectFrom(Vet.class, SpecialtyNamesByVet.class, RAW."""
\{Vet.class}, JSON_OBJECTAGG(\{Specialty.class})""")
.innerJoin(VetSpecialty.class).on(Vet.class)
.innerJoin(Specialty.class).on(VetSpecialty.class)
.append(RAW."GROUP BY \{Vet.class}.id")
.getResultList();
} catch (PersistenceException _) {
// H2 Does not support JSON_OBJECTAGG. We only check the expected SQL.
}
});
}

// No need to specify the sub types here, as we're automatically registering the implementations of the sealed interface.
Expand Down
2 changes: 1 addition & 1 deletion storm-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>st.orm</groupId>
<artifactId>storm-framework</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>storm-kotlin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
Expand All @@ -44,7 +43,7 @@
import static java.lang.System.identityHashCode;
import static java.lang.reflect.Proxy.newProxyInstance;
import static java.util.Optional.empty;
import static st.orm.template.SqlInterceptor.consume;
import static st.orm.template.SqlInterceptor.observeThrowing;

public final class KORMTemplateImpl extends KQueryTemplateImpl implements KORMTemplate {
private final static ORMReflection REFLECTION = Providers.getORMReflection();
Expand Down Expand Up @@ -183,18 +182,20 @@ private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> interfacesFou
private <T extends KRepository> T wrapRepository(@Nonnull T repository) {
return (T) newProxyInstance(repository.getClass().getClassLoader(), getAllInterfaces(repository.getClass()).toArray(new Class[0]), (_, method, args) -> {
var lastSql = new AtomicReference<Sql>();
try (var _ = consume(lastSql::setPlain)) {
try {
return method.invoke(repository, args);
} catch (Exception | Error e) {
throw e;
} catch (Throwable e) {
throw new PersistenceException(e);
}
try {
return observeThrowing(lastSql::setPlain, () -> {
try {
return method.invoke(repository, args);
} catch (Exception | Error e) {
throw e;
} catch (Throwable e) {
throw new PersistenceException(e);
}
});
} catch (InvocationTargetException e) {
try {
throw e.getTargetException();
} catch (SQLException | PersistenceException ex) {
} catch (Exception ex) {
Sql sql = lastSql.getPlain();
if (sql != null && ex.getSuppressed().length == 0) {
ex.addSuppressed(new SqlTemplateException(STR."""
Expand Down
2 changes: 1 addition & 1 deletion storm-mariadb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>st.orm</groupId>
<artifactId>storm-framework</artifactId>
<version>1.3.2</version>
<version>1.3.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>storm-mariadb</artifactId>
Expand Down
Loading