DataSourceConfig — пакет: config
Код: Выделить всё
package com.kleingroup.reservations.config;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import javax.sql.DataSource;
import java.util.HashMap;
@Configuration
public class DataSourceConfig {
@Bean(name = "dataSource")
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "newDataSource")
@ConfigurationProperties(prefix = "spring.new-datasource")
public DataSource newDataSource() {
return DataSourceBuilder.create().build();
}
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
@Qualifier("dataSource") DataSource dataSource) {
return createEntityManagerFactory(dataSource);
}
@Bean(name = "newEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean newEntityManagerFactory(
@Qualifier("newDataSource") DataSource newDataSource) {
return createEntityManagerFactory(newDataSource);
}
private LocalContainerEntityManagerFactoryBean createEntityManagerFactory(DataSource dataSource) {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setPackagesToScan("com.kleingroup.reservations.model");
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
em.setJpaPropertyMap(hibernateProperties());
return em;
}
@Bean(name = "transactionManager")
public JpaTransactionManager transactionManager(
@Qualifier("entityManagerFactory") LocalContainerEntityManagerFactoryBean entityManagerFactory) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory.getObject());
return transactionManager;
}
@Bean(name = "newTransactionManager")
public JpaTransactionManager newTransactionManager(
@Qualifier("newEntityManagerFactory") LocalContainerEntityManagerFactoryBean newEntityManagerFactory) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(newEntityManagerFactory.getObject());
return transactionManager;
}
private HashMap hibernateProperties() {
HashMap properties = new HashMap();
properties.put("hibernate.hbm2ddl.auto", "none");
properties.put("hibernate.ddl-auto", "none");
properties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
properties.put("hibernate.temp.use_jdbc_metadata_defaults", "false");
properties.put("jpa.show-sql", "true");
properties.put("spring.jpa.show-sql", "true");
return properties;
}
}
Код: Выделить всё
package com.kleingroup.reservations.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableJpaRepositories(
basePackages = "com.kleingroup.reservations.repository",
entityManagerFactoryRef = "newEntityManagerFactory",
transactionManagerRef = "newTransactionManager"
)
@EnableTransactionManagement
public class NewDatabaseConfig {
}
Код: Выделить всё
package com.kleingroup.reservations.model;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Entity
@Table(name = "rooms")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Room {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "room_number", nullable = false, unique = true)
private Long roomNumber;
@Column(nullable = false)
private String description;
@Column(nullable = false)
private Boolean availability;
}
Код: Выделить всё
package com.kleingroup.reservations.repository;
import com.kleingroup.reservations.model.Room;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface NewRoomRepository extends JpaRepository {
Optional findByRoomNumber(Long roomNumber);
}
Код: Выделить всё
{
private final RoomRepository roomRepository;
private final RoomMaintenanceRepository roomMaintenanceRepository;
private final NewRoomRepository newRoomRepository;
@Autowired
public RoomService(RoomRepository roomRepository, RoomMaintenanceRepository roomMaintenanceRepository, NewRoomRepository newRoomRepository) {
this.roomRepository = roomRepository;
this.roomMaintenanceRepository = roomMaintenanceRepository;
this.newRoomRepository = newRoomRepository;
System.out.println("NewRoomRepository connected to newDataSource: " + newRoomRepository);
}
public List getAllRooms() {
return roomRepository.findAll();
}
public long countAllRooms() {
return roomRepository.count();
}
public Room getRoomById(Long id){
return roomRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Room not found with ID: " + id));
}
public Room getRoomByRoomNumber(Long roomNumber){
return roomRepository.findByRoomNumber(roomNumber)
.orElseThrow(() -> new ResourceNotFoundException("Room not found with ID: " + roomNumber));
}
public Room updateRoomAvailability(Long roomId, Boolean availability, String reason) {
Room room = getRoomById(roomId);
room.setAvailability(availability);
roomRepository.save(room);
RoomMaintenance maintenanceRecord = new RoomMaintenance();
maintenanceRecord.setRoom(room);
maintenanceRecord.setReason(reason);
maintenanceRecord.setDatetime(LocalDateTime.now());
roomMaintenanceRepository.save(maintenanceRecord);
return room;
}
@Transactional(transactionManager = "newTransactionManager")
public List updateRooms(List rooms) {
System.out.println("Updating rooms in new database");
return rooms.stream()
.map(room -> newRoomRepository.findById(room.getId())
.map(existingRoom -> {
existingRoom.setAvailability(room.getAvailability());
System.out.println("Updating room ID: " + existingRoom.getId() + " to availability: " + existingRoom.getAvailability());
return newRoomRepository.save(existingRoom);
})
.orElseThrow(() -> new RuntimeException("Room not found with id " + room.getId())))
.collect(Collectors.toList());
}
}
Код: Выделить всё
{
private final RoomService roomService;
private final RestTemplate restTemplate;
private final TokenService tokenService;
private final LocalDate productionDate = LocalDate.of(2024, 9, 1); // Data di inizio produzione
@Autowired
public ScheduledService(RoomService roomService, RestTemplate restTemplate, TokenService tokenService) {
this.roomService = roomService;
this.restTemplate = restTemplate;
this.tokenService = tokenService;
}
@Scheduled(cron = "0 * * * * ?")
public void sendRoomsToNewBackend() {
LocalDate currentDate = LocalDate.now();
if (!currentDate.isBefore(productionDate)) {
String token = tokenService.getToken();
List rooms = roomService.getAllRooms();
/*updateRoomsInNewBackend(rooms, token);*/
updateRoomsInNewDatabase(rooms);
} else {
System.out.println("The synchronization was not performed because the current date is before 01/09/2024.");
}
}
private void updateRoomsInNewBackend(List rooms, String token) {
String url = "http://localhost:8081/api/rooms/update";
try {
HttpHeaders headers = new HttpHeaders();
headers.setBearerAuth(token);
headers.set("Content-Type", "application/json");
HttpEntity entity = new HttpEntity(rooms, headers);
ResponseEntity response = restTemplate.exchange(url, HttpMethod.PUT, entity, Void.class);
if (response.getStatusCode().is2xxSuccessful()) {
System.out.println("Rooms updated successfully in the new backend.");
} else {
System.out.println("Failed to update rooms in the new backend. Status: " + response.getStatusCode());
}
} catch (Exception e) {
System.out.println("Failed to update rooms: " + e.getMessage());
}
}
private void updateRoomsInNewDatabase(List rooms) {
try {
System.out.println("Starting to update rooms in the new database...");
roomService.updateRooms(rooms);
System.out.println("Rooms updated successfully in the new database.");
} catch (Exception e) {
System.out.println("Failed to update rooms in the new database: " + e.getMessage());
}
}
}
Код: Выделить всё
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto = none
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
logging.level.org.springframework=DEBUG
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
spring.main.allow-bean-definition-overriding=true
logging.level.org.springframework.orm.jpa.JpaTransactionManager=DEBUG
logging.level.org.springframework.transaction=DEBUG
logging.level.org.springframework.security=DEBUG
Код: Выделить всё
spring:
datasource:
jdbc-url: jdbc:mysql://localhost:3306/reservations_old?allowPublicKeyRetrieval=true&useSSL=false
username: developer
password: ${spring.datasource.password}
new-datasource:
jdbc-url: jdbc:mysql://localhost:3306/reservations?allowPublicKeyRetrieval=true&useSSL=false
username: developer
password: ${spring.datasource.password}
hikari:
pool-name: HikariPool-2
jpa:
show-sql: true
hibernate:
ddl-auto: update
format_sql: true
use_sql_comments: true
Код: Выделить всё
Updating room ID: 20 to availability: true
2024-09-17T17:09:00.215+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2024-09-17T17:09:00.215+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Opened new EntityManager [SessionImpl(1053643402)] for JPA transaction
2024-09-17T17:09:00.215+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@26fb13fb]
2024-09-17T17:09:00.215+02:00 DEBUG 32156 --- [ scheduling-1] org.hibernate.SQL : select r1_0.id,r1_0.availability,r1_0.description,r1_0.room_number from rooms r1_0 where r1_0.id=?
2024-09-17T17:09:00.215+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Initiating transaction commit
2024-09-17T17:09:00.215+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Committing JPA transaction on EntityManager [SessionImpl(1053643402)]
2024-09-17T17:09:00.216+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Closing JPA EntityManager [SessionImpl(1053643402)] after transaction
2024-09-17T17:09:00.216+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Resuming suspended transaction after completion of inner transaction
2024-09-17T17:09:00.216+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.findById]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
2024-09-17T17:09:00.216+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Opened new EntityManager [SessionImpl(937557525)] for JPA transaction
2024-09-17T17:09:00.216+02:00 DEBUG 32156 --- [ scheduling-1] o.s.jdbc.datasource.DataSourceUtils : Setting JDBC Connection [HikariProxyConnection@1901015754 wrapping com.mysql.cj.jdbc.ConnectionImpl@5fd9a0a8] read-only
2024-09-17T17:09:00.216+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@989930c]
2024-09-17T17:09:00.216+02:00 DEBUG 32156 --- [ scheduling-1] org.hibernate.SQL : select r1_0.id,r1_0.availability,r1_0.description,r1_0.room_number from rooms r1_0 where r1_0.id=?
2024-09-17T17:09:00.217+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Initiating transaction commit
2024-09-17T17:09:00.217+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Committing JPA transaction on EntityManager [SessionImpl(937557525)]
2024-09-17T17:09:00.217+02:00 DEBUG 32156 --- [ scheduling-1] o.s.jdbc.datasource.DataSourceUtils : Resetting read-only flag of JDBC Connection [HikariProxyConnection@1901015754 wrapping com.mysql.cj.jdbc.ConnectionImpl@5fd9a0a8]
2024-09-17T17:09:00.217+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Closing JPA EntityManager [SessionImpl(937557525)] after transaction
2024-09-17T17:09:00.217+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Resuming suspended transaction after completion of inner transaction
Updating room ID: 21 to availability: true
2024-09-17T17:09:00.217+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2024-09-17T17:09:00.217+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Opened new EntityManager [SessionImpl(1427249451)] for JPA transaction
2024-09-17T17:09:00.217+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@5d435e15]
2024-09-17T17:09:00.218+02:00 DEBUG 32156 --- [ scheduling-1] org.hibernate.SQL : select r1_0.id,r1_0.availability,r1_0.description,r1_0.room_number from rooms r1_0 where r1_0.id=?
2024-09-17T17:09:00.218+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Initiating transaction commit
2024-09-17T17:09:00.218+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Committing JPA transaction on EntityManager [SessionImpl(1427249451)]
2024-09-17T17:09:00.218+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Closing JPA EntityManager [SessionImpl(1427249451)] after transaction
2024-09-17T17:09:00.218+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Resuming suspended transaction after completion of inner transaction
2024-09-17T17:09:00.218+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.findById]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
2024-09-17T17:09:00.218+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Opened new EntityManager [SessionImpl(583667673)] for JPA transaction
2024-09-17T17:09:00.218+02:00 DEBUG 32156 --- [ scheduling-1] o.s.jdbc.datasource.DataSourceUtils : Setting JDBC Connection [HikariProxyConnection@1609968598 wrapping com.mysql.cj.jdbc.ConnectionImpl@5fd9a0a8] read-only
2024-09-17T17:09:00.219+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@13093730]
2024-09-17T17:09:00.219+02:00 DEBUG 32156 --- [ scheduling-1] org.hibernate.SQL : select r1_0.id,r1_0.availability,r1_0.description,r1_0.room_number from rooms r1_0 where r1_0.id=?
2024-09-17T17:09:00.219+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Initiating transaction commit
2024-09-17T17:09:00.219+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Committing JPA transaction on EntityManager [SessionImpl(583667673)]
2024-09-17T17:09:00.220+02:00 DEBUG 32156 --- [ scheduling-1] o.s.jdbc.datasource.DataSourceUtils : Resetting read-only flag of JDBC Connection [HikariProxyConnection@1609968598 wrapping com.mysql.cj.jdbc.ConnectionImpl@5fd9a0a8]
2024-09-17T17:09:00.220+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Closing JPA EntityManager [SessionImpl(583667673)] after transaction
2024-09-17T17:09:00.220+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Resuming suspended transaction after completion of inner transaction
Updating room ID: 22 to availability: true
2024-09-17T17:09:00.220+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2024-09-17T17:09:00.220+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Opened new EntityManager [SessionImpl(1422863696)] for JPA transaction
2024-09-17T17:09:00.220+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@3dfd591e]
2024-09-17T17:09:00.220+02:00 DEBUG 32156 --- [ scheduling-1] org.hibernate.SQL : select r1_0.id,r1_0.availability,r1_0.description,r1_0.room_number from rooms r1_0 where r1_0.id=?
2024-09-17T17:09:00.220+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Initiating transaction commit
2024-09-17T17:09:00.220+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Committing JPA transaction on EntityManager [SessionImpl(1422863696)]
2024-09-17T17:09:00.221+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Closing JPA EntityManager [SessionImpl(1422863696)] after transaction
2024-09-17T17:09:00.221+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Resuming suspended transaction after completion of inner transaction
2024-09-17T17:09:00.221+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.findById]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
2024-09-17T17:09:00.221+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Opened new EntityManager [SessionImpl(1651910372)] for JPA transaction
2024-09-17T17:09:00.221+02:00 DEBUG 32156 --- [ scheduling-1] o.s.jdbc.datasource.DataSourceUtils : Setting JDBC Connection [HikariProxyConnection@1818190285 wrapping com.mysql.cj.jdbc.ConnectionImpl@5fd9a0a8] read-only
2024-09-17T17:09:00.221+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@fe3394a]
2024-09-17T17:09:00.221+02:00 DEBUG 32156 --- [ scheduling-1] org.hibernate.SQL : select r1_0.id,r1_0.availability,r1_0.description,r1_0.room_number from rooms r1_0 where r1_0.id=?
2024-09-17T17:09:00.222+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Initiating transaction commit
2024-09-17T17:09:00.222+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Committing JPA transaction on EntityManager [SessionImpl(1651910372)]
2024-09-17T17:09:00.222+02:00 DEBUG 32156 --- [ scheduling-1] o.s.jdbc.datasource.DataSourceUtils : Resetting read-only flag of JDBC Connection [HikariProxyConnection@1818190285 wrapping com.mysql.cj.jdbc.ConnectionImpl@5fd9a0a8]
2024-09-17T17:09:00.222+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Closing JPA EntityManager [SessionImpl(1651910372)] after transaction
2024-09-17T17:09:00.222+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Resuming suspended transaction after completion of inner transaction
Updating room ID: 23 to availability: true
2024-09-17T17:09:00.222+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
2024-09-17T17:09:00.222+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Opened new EntityManager [SessionImpl(1547022695)] for JPA transaction
2024-09-17T17:09:00.222+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@3c294395]
2024-09-17T17:09:00.222+02:00 DEBUG 32156 --- [ scheduling-1] org.hibernate.SQL : select r1_0.id,r1_0.availability,r1_0.description,r1_0.room_number from rooms r1_0 where r1_0.id=?
2024-09-17T17:09:00.223+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Initiating transaction commit
2024-09-17T17:09:00.223+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Committing JPA transaction on EntityManager [SessionImpl(1547022695)]
2024-09-17T17:09:00.223+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Closing JPA EntityManager [SessionImpl(1547022695)] after transaction
2024-09-17T17:09:00.223+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Resuming suspended transaction after completion of inner transaction
2024-09-17T17:09:00.223+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.findById]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly
2024-09-17T17:09:00.223+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Opened new EntityManager [SessionImpl(1264198256)] for JPA transaction
2024-09-17T17:09:00.223+02:00 DEBUG 32156 --- [ scheduling-1] o.s.jdbc.datasource.DataSourceUtils : Setting JDBC Connection [HikariProxyConnection@533062505 wrapping com.mysql.cj.jdbc.ConnectionImpl@5fd9a0a8] read-only
2024-09-17T17:09:00.224+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@43f245d2]
2024-09-17T17:09:00.224+02:00 DEBUG 32156 --- [ scheduling-1] org.hibernate.SQL : select r1_0.id,r1_0.availability,r1_0.description,r1_0.room_number from rooms r1_0 where r1_0.id=?
2024-09-17T17:09:00.224+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Initiating transaction commit
2024-09-17T17:09:00.224+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Committing JPA transaction on EntityManager [SessionImpl(1264198256)]
2024-09-17T17:09:00.225+02:00 DEBUG 32156 --- [ scheduling-1] o.s.jdbc.datasource.DataSourceUtils : Resetting read-only flag of JDBC Connection [HikariProxyConnection@533062505 wrapping com.mysql.cj.jdbc.ConnectionImpl@5fd9a0a8]
2024-09-17T17:09:00.226+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Closing JPA EntityManager [SessionImpl(1264198256)] after transaction
2024-09-17T17:09:00.226+02:00 DEBUG 32156 --- [ scheduling-1] o.s.orm.jpa.JpaTransactionManager : Resuming suspended transaction after completion of inner transaction
Updating room ID: 24 to availability: true
Подробнее здесь: https://stackoverflow.com/questions/789 ... -databasee
Мобильная версия