This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/main by this push:
new 036191dd994 Bumps Spring Boot 3.4.3 -> 3.4.4 (part 2 - JPA compile fix)
036191dd994 is described below
commit 036191dd9948454c3d1df61eb1735562bc7f7b12
Author: Andi Huber <[email protected]>
AuthorDate: Fri Mar 21 06:29:46 2025 +0100
Bumps Spring Boot 3.4.3 -> 3.4.4 (part 2 - JPA compile fix)
---
.../CausewayModulePersistenceJpaEclipselink.java | 65 ++++++++++------------
1 file changed, 29 insertions(+), 36 deletions(-)
diff --git
a/persistence/jpa/eclipselink/src/main/java/org/apache/causeway/persistence/jpa/eclipselink/CausewayModulePersistenceJpaEclipselink.java
b/persistence/jpa/eclipselink/src/main/java/org/apache/causeway/persistence/jpa/eclipselink/CausewayModulePersistenceJpaEclipselink.java
index 5b4245ebac5..4a51d91c981 100644
---
a/persistence/jpa/eclipselink/src/main/java/org/apache/causeway/persistence/jpa/eclipselink/CausewayModulePersistenceJpaEclipselink.java
+++
b/persistence/jpa/eclipselink/src/main/java/org/apache/causeway/persistence/jpa/eclipselink/CausewayModulePersistenceJpaEclipselink.java
@@ -20,7 +20,6 @@
import java.sql.SQLException;
import java.util.Map;
-
import javax.sql.DataSource;
import jakarta.inject.Inject;
@@ -100,6 +99,11 @@ protected Map<String, Object> getVendorProperties() {
return elSettings.asMap();
}
+ @Override
+ protected Map<String, Object> getVendorProperties(final DataSource
dataSource) {
+ return elSettings.asMap();
+ }
+
/**
* integrates with settings from causeway.persistence.schema.*
*/
@@ -119,7 +123,7 @@ protected static DataSource autoCreateSchemas(
var s = con.createStatement();
for(var schema : persistenceSchemaConf.getAutoCreateSchemas())
{
-
s.execute(String.format(persistenceSchemaConf.getCreateSchemaSqlTemplate(),
schema));
+
s.execute(persistenceSchemaConf.getCreateSchemaSqlTemplate().formatted(schema));
}
}
@@ -138,8 +142,8 @@ protected static JpaProperties addAdditionalOrmFiles(
var persistenceSchemaConf =
causewayConfiguration.getPersistence().getSchema();
persistenceSchemaConf.getAdditionalOrmFiles()
- .forEach(schema->properties.getMappingResources()
- .add(String.format("META-INF/orm-%s.xml", schema)));
+ .forEach(schema->properties.getMappingResources()
+ .add("META-INF/orm-%s.xml".formatted(schema)));
if(!properties.getMappingResources().isEmpty()) {
log.info("using mapping-resources {}",
properties.getMappingResources());
@@ -160,25 +164,21 @@ private EclipseLinkJpaDialect eclipselinkJpaDialect() {
@Override
public DataAccessException translateExceptionIfPossible(final
RuntimeException ex) {
- if(ex instanceof DataAccessException) {
- return (DataAccessException)ex; // has already been
translated to Spring's hierarchy
- }
+ // has already been translated to Spring's hierarchy
+ if(ex instanceof DataAccessException dataAccessException)
return dataAccessException;
// if its eg. a DatabaseException, it might wrap a
java.sql.SQLException
if(getJdbcExceptionTranslator() != null
- && ex.getCause() instanceof SQLException) {
+ && ex.getCause() instanceof SQLException sqlException)
{
//converts SQL exceptions to Spring's hierarchy
var translatedEx = getJdbcExceptionTranslator()
.translate(
"JPA operation: " + ex.getMessage(),
extractSqlStringFromException(ex),
- (SQLException) ex.getCause());
-
- if(translatedEx!=null) {
- return translatedEx;
- }
+ sqlException);
+ if(translatedEx!=null) return translatedEx;
}
/* (null-able) converts javax.persistence exceptions to
Spring's hierarchy
@@ -196,27 +196,23 @@ public DataAccessException
translateExceptionIfPossible(final RuntimeException e
&& getJdbcExceptionTranslator() != null) {
var translatedSqlEx = _Exceptions.streamCausalChain(ex)
- .filter(nextEx->nextEx instanceof SQLException)
- .map(SQLException.class::cast)
- //converts SQL exceptions to Spring's hierarchy
- .map(nextEx->getJdbcExceptionTranslator()
- .translate(
- "JPA operation: " + nextEx.getMessage(),
- extractSqlStringFromException(nextEx),
- nextEx))
- .filter(_NullSafe::isPresent) //CAUSEWAY-3282
- .findFirst()
- .orElse(null);
-
- if(translatedSqlEx!=null) {
- return translatedSqlEx;
- }
-
+ .filter(SQLException.class::isInstance)
+ .map(SQLException.class::cast)
+ //converts SQL exceptions to Spring's hierarchy
+ .map(nextEx->getJdbcExceptionTranslator()
+ .translate(
+ "JPA operation: " +
nextEx.getMessage(),
+ extractSqlStringFromException(nextEx),
+ nextEx))
+ .filter(_NullSafe::isPresent) //CAUSEWAY-3282
+ .findFirst()
+ .orElse(null);
+
+ if(translatedSqlEx!=null) return translatedSqlEx;
}
// (null-able)
return translatedEx;
-
}
// -- HELPER
@@ -251,12 +247,9 @@ private SQLExceptionTranslator
getJdbcExceptionTranslator() {
*/
private static SQLExceptionTranslator newJdbcExceptionTranslator(final
Object connectionFactory) {
// Check for PersistenceManagerFactory's DataSource.
- if (connectionFactory instanceof DataSource) {
- return new SQLErrorCodeSQLExceptionTranslator((DataSource)
connectionFactory);
- }
- else {
- return new SQLStateSQLExceptionTranslator();
- }
+ return connectionFactory instanceof DataSource dataSource
+ ? new SQLErrorCodeSQLExceptionTranslator(dataSource)
+ : new SQLStateSQLExceptionTranslator();
}
}