Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove EnableTransactionManagement annotation #307

Merged
merged 1 commit into from
Sep 30, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.StringReader;
import java.lang.invoke.MethodHandles;
import java.math.BigDecimal;
import java.sql.Blob;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
Expand All @@ -39,7 +38,6 @@
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -74,7 +72,7 @@
*/
// Without proxyTargetClass = true the test webapp will give: Bean named 'proofOfMigrationStorage' is expected to be of
// type 'nl.nn.testtool.storage.proofofmigration.ProofOfMigrationStorage' but was actually of type 'jdk.proxy3.$Proxy26'
@EnableTransactionManagement(proxyTargetClass = true)
// @EnableTransactionManagement(proxyTargetClass = true)
// REQUIRES_NEW to prevent interference with transactions in the application using Ladybug. E.g. when an error occurs in
// a Frank!Framework adapter the insert of the Ladybug report should not be rolled back (which happens otherwise because
// transactions are thread bound and Ladybug runs in the same thread). With NOT_SUPPORTED PostgreSQL will complain about
Expand Down Expand Up @@ -229,7 +227,7 @@ public void setValues(PreparedStatement ps) throws SQLException {
i++;
}
}
ps.setBlob(i, new ByteArrayInputStream(reportBytes));
ps.setBytes(i, reportBytes);
i++;
if (isStoreReportXml()) {
ps.setClob(i, new StringReader(reportXml));
Expand Down Expand Up @@ -270,15 +268,15 @@ public Report getReport(Integer storageId) throws StorageException {
String query = "select report from " + getTable() + " where " + getStorageIdColumn() + " = ?";
log.debug("Get report query: " + query);
List<Report> result = ladybugJdbcTemplate.query(query, new Object[]{storageId}, new int[] {Types.INTEGER},
(resultSet, rowNum) -> getReport(storageId, resultSet.getBlob(1)));
(resultSet, rowNum) -> getReport(storageId, resultSet.getBytes(1)));
return result.get(0);
}

// StorageException is allowed by Storage.getReport(), hence no need to handle it in the lambda expression that will
// call this method
@SneakyThrows
private static Report getReport(Integer storageId, Blob blob) {
return Import.getReport(blob.getBinaryStream(), storageId, blob.length(), log);
private static Report getReport(Integer storageId, byte[] blob) {
return Import.getReport(new ByteArrayInputStream(blob), storageId, (long) blob.length, log);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public String provideTrailingFirstRowsHint(int rowCount) {
}

public String getRowNumber(String order, String sort) {
if ("Oracle".equals(commonDatabaseName) || "Microsoft SQL Server".equals(commonDatabaseName)) {
if ("Oracle".equals(commonDatabaseName)) {
return "row_number() over (order by "+order+(sort==null?"":" "+sort)+") "+getRowNumberShortName();
}
return "";
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/ladybug/DatabaseChangelog_Debug.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd"
>
<changeSet id="Ladybug:1" author="Jaco de Groot">
<property name="BLOB_FIELD_TYPE" value="bytea" dbms="postgresql"/>
<property name="BLOB_FIELD_TYPE" value="blob" dbms="!postgresql"/>

<changeSet id="Ladybug:1" author="Jaco de Groot" failOnError="false">
<comment>Add table LADYBUG</comment>
<createTable tableName="LADYBUG">
<column name="STORAGEID" type="INTEGER" autoIncrement="true">
Expand Down
Loading