Skip to content

Commit

Permalink
x1250 Remove entityManager.isJoinedToTransaction because somehow it d…
Browse files Browse the repository at this point in the history
…oesn't work
  • Loading branch information
khelwood committed Dec 4, 2024
1 parent aaa2b66 commit 3320a35
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/uk/ac/sanger/sccp/stan/repo/BarcodeIntRepo.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package uk.ac.sanger.sccp.stan.repo;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import uk.ac.sanger.sccp.stan.service.BarcodeUtils;

import javax.persistence.*;
Expand All @@ -14,7 +15,7 @@ public class BarcodeIntRepo {

/** Gets the next barcode seed and marks it as used */
public int next() {
if (!entityManager.isJoinedToTransaction()) {
if (!TransactionSynchronizationManager.isActualTransactionActive()) {
throw new TransactionRequiredException();
}
Query select = entityManager.createNativeQuery("select seed from barcode_int where not used order by id limit 1");
Expand All @@ -27,7 +28,7 @@ public int next() {

/** Gets the next <tt>n</tt> barcode seeds and marks them used */
public List<Integer> next(int n) {
if (!entityManager.isJoinedToTransaction()) {
if (!TransactionSynchronizationManager.isActualTransactionActive()) {
throw new TransactionRequiredException();
}
Query select = entityManager.createNativeQuery("select seed from barcode_int where not used order by id limit ?1");
Expand Down

0 comments on commit 3320a35

Please sign in to comment.