-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed as not planned
Labels
for: external-projectFor an external project and not something we can fixFor an external project and not something we can fix
Description
Using the native query in code below I've found a memory leak.
@Service
@RequiredArgsConstructor
public class TestService {
private final List<Status> statuses = List.of(Status.NOT_ACTIVE, Status.ACTIVE);
private final TestRepository repository;
@Transactional
public void test() {
var result = repository.findByStatusForUpdate(statuses);
// todo
}
}
public interface TestRepository extends JpaRepository<TestEntity, Long> {
@Query(value = "SELECT * FROM test WHERE status_dict_id in (:statuses) FOR UPDATE SKIP LOCKED", nativeQuery = true)
List<TestEntity> findByStatusForUpdate(List<Status> statuses);
}
@Entity
public class TestEntity {
@Id
private Long id;
@Column(name = "status_dict_id")
@Enumerated(EnumType.ORDINAL)
private Status status;
}
public enum Status {
UNDEFINED,
BLOCKED,
ACTIVE,
NOT_ACTIVE,
}
Hibernate keeps statuses and and consumes memory. Database - postgres.
Metadata
Metadata
Assignees
Labels
for: external-projectFor an external project and not something we can fixFor an external project and not something we can fix