Skip to content

Instantly share code, notes, and snippets.

View lmonkiewicz's full-sized avatar

Łukasz Monkiewicz lmonkiewicz

View GitHub Profile
@lmonkiewicz
lmonkiewicz / instructions.md
Last active March 30, 2026 12:29
lob-problem

Problem z LOB i zagnieżdżonymi transakcjami w Hibernate/Oracle

Rozumiem problem. Kluczowa kwestia: Oracle JDBC nie pozwala na równoczesne operacje LOB na tym samym połączeniu, a REQUIRES_NEW w Spring domyślnie nie gwarantuje nowego połączenia — tylko nową transakcję logiczną.

Co się dzieje krok po kroku

Masz mniej więcej taki flow:

  1. Metoda A (@Transactional) — otwiera transakcję, pobiera CLOB jako InputStream, parsuje StAX-em
  2. W trakcie parsowania wywołujesz Metodę B (@Transactional(REQUIRES_NEW)) — Spring zawiesza transakcję A, otwiera nową transakcję B
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.type.SqlTypes;
import org.springframework.data.domain.AbstractAggregateRoot;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.util.UUID;
import java.nio.ByteBuffer;
import java.util.Base64;
import java.util.UUID;
public class Base64ToUUID {
// Method to convert UUID to base64 (without padding)
public static String uuidToBase64(UUID uuid) {
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
byteBuffer.putLong(uuid.getMostSignificantBits());
metricOperations.increment(KafkaMetrics.METRIC_NAME,
Tags.of(KafkaTags.topic(topic),
KafkaTags.exception(exception.getClass().getName()),
KafkaTags.processor(context.applicationId())
));
@RequiredArgsConstructor
@Component
public class MetricOperations {
private final MeterRegistry meterRegistry;
public Counter counter(String metricName, Tags tags) {
return meterRegistry.counter(metricName, tags);
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
package pl.effectivedev.iban.ibantest;
import java.math.BigInteger;
import java.time.LocalDate;
import java.util.Map;
import java.util.TreeMap;
public class IbanService {
Map<String, IbanStructure> structures = new TreeMap<>();
@lmonkiewicz
lmonkiewicz / pom.xml
Created February 9, 2023 09:52
openapi openapi openapi
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>6.2.1</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<goals>
<goal>generate</goal>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
spring:
cloud:
stream:
kafka:
binder:
brokers: localhost:9092
autoCreateTopics: true
configuration:
sasl.mechanism: PLAIN