getting rid of some FIXMEs
This commit is contained in:
parent
575fe9f88a
commit
b3391578ec
@ -6,7 +6,6 @@ import net.hostsharing.hsadminng.hs.hosting.asset.HsHostingAssetType;
|
|||||||
import net.hostsharing.hsadminng.hs.validation.PropertiesProvider;
|
import net.hostsharing.hsadminng.hs.validation.PropertiesProvider;
|
||||||
|
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.FlushModeType;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static net.hostsharing.hsadminng.hs.validation.BooleanProperty.booleanProperty;
|
import static net.hostsharing.hsadminng.hs.validation.BooleanProperty.booleanProperty;
|
||||||
@ -54,7 +53,6 @@ class HsUnixUserHostingAssetValidator extends HostingAssetEntityValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Integer computeUserId(final EntityManager em, final PropertiesProvider propertiesProvider) {
|
private static Integer computeUserId(final EntityManager em, final PropertiesProvider propertiesProvider) {
|
||||||
em.setFlushMode(FlushModeType.COMMIT); // FIXME: check and remove or reset
|
|
||||||
final Object result = em.createNativeQuery("SELECT nextval('hs_hosting.asset_unixuser_system_id_seq')", Integer.class)
|
final Object result = em.createNativeQuery("SELECT nextval('hs_hosting.asset_unixuser_system_id_seq')", Integer.class)
|
||||||
.getSingleResult();
|
.getSingleResult();
|
||||||
return (Integer) result;
|
return (Integer) result;
|
||||||
|
@ -106,9 +106,7 @@ public class HsOfficeDebitorController implements HsOfficeDebitorsApi {
|
|||||||
|
|
||||||
final var entityToSave = mapper.map(body, HsOfficeDebitorEntity.class, RESOURCE_TO_ENTITY_POSTMAPPER);
|
final var entityToSave = mapper.map(body, HsOfficeDebitorEntity.class, RESOURCE_TO_ENTITY_POSTMAPPER);
|
||||||
|
|
||||||
final var savedEntity = debitorRepo.save(entityToSave).load();
|
final var savedEntity = debitorRepo.save(entityToSave).reload(em);
|
||||||
// em.flush(); // FIXME: necessary?
|
|
||||||
// em.refresh(savedEntity);
|
|
||||||
|
|
||||||
final var uri =
|
final var uri =
|
||||||
MvcUriComponentsBuilder.fromController(getClass())
|
MvcUriComponentsBuilder.fromController(getClass())
|
||||||
|
@ -3,6 +3,7 @@ package net.hostsharing.hsadminng.persistence;
|
|||||||
|
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
|
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface BaseEntity<T extends BaseEntity<?>> {
|
public interface BaseEntity<T extends BaseEntity<?>> {
|
||||||
@ -15,4 +16,10 @@ public interface BaseEntity<T extends BaseEntity<?>> {
|
|||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (T) this;
|
return (T) this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
default T reload(final EntityManager em) {
|
||||||
|
em.flush();
|
||||||
|
em.refresh(this);
|
||||||
|
return load();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user