From 768d605845c6479373a51975b48eab7807c5a29c Mon Sep 17 00:00:00 2001 From: mrfoxygmfr Date: Mon, 24 Mar 2025 01:32:31 +0300 Subject: fix(db): save many-to-one references --- .../ru/mrfoxygmfr/warehouse_accounting/db/config/HibernateConfig.java | 1 + .../java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java | 4 ++-- .../mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java | 4 ++-- .../ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java | 2 +- .../ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/main') diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/config/HibernateConfig.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/config/HibernateConfig.java index 7f7948a..014db7b 100644 --- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/config/HibernateConfig.java +++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/config/HibernateConfig.java @@ -27,6 +27,7 @@ public class HibernateConfig { sessionFactory.setPackagesToScan("ru.mrfoxygmfr.warehouse_accounting.db.models"); Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.enable_lazy_load_no_trans", "true"); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "update"); hibernateProperties.setProperty("connection_pool_size", "1"); diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java index 51b8bbd..d1eb400 100644 --- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java +++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/Operation.java @@ -21,7 +21,7 @@ public class Operation { private int id; @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "partner_id", referencedColumnName = "id", insertable = false, updatable = false) + @JoinColumn(name = "partner_id", referencedColumnName = "id") @NonNull private Partner partner; @@ -53,7 +53,7 @@ public class Operation { private String address; @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "responsible_id", referencedColumnName = "id", insertable = false, updatable = false) + @JoinColumn(name = "responsible_id", referencedColumnName = "id") @NonNull private PartnerContact responsible; diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java index 9eaeab1..2a842a2 100644 --- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java +++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/OperationProducts.java @@ -18,12 +18,12 @@ public class OperationProducts { private int id; @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "operation_id", referencedColumnName = "id", insertable = false, updatable = false) + @JoinColumn(name = "operation_id", referencedColumnName = "id") @NonNull private Operation operation; @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "product_id", referencedColumnName = "id", insertable = false, updatable = false) + @JoinColumn(name = "product_id", referencedColumnName = "id") @NonNull private Product product; diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java index e25d178..c783d64 100644 --- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java +++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/PartnerContact.java @@ -18,7 +18,7 @@ public class PartnerContact { private int id; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "partner_id", referencedColumnName = "id", insertable = false, updatable = false) + @JoinColumn(name = "partner_id", referencedColumnName = "id") @NonNull private Partner partner; diff --git a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java index 7c24e5b..640ef6f 100644 --- a/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java +++ b/src/main/java/ru/mrfoxygmfr/warehouse_accounting/db/models/ProductSlots.java @@ -21,12 +21,12 @@ public class ProductSlots { @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "product_id", referencedColumnName = "id", insertable = false, updatable = false) + @JoinColumn(name = "product_id", referencedColumnName = "id") @NonNull private Product product; @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "slot_id", referencedColumnName = "id", insertable = false, updatable = false) + @JoinColumn(name = "slot_id", referencedColumnName = "id") @NonNull private StorageSlot slot; -- cgit mrf-deployment