[FIX] update of the @ManyToMany values

This commit is contained in:
Edouard DUPIN 2025-04-13 15:49:58 +02:00
parent 464f844eed
commit 7a7ca29081
2 changed files with 9 additions and 5 deletions

View File

@ -1172,7 +1172,7 @@ public class DBAccessSQL extends DBAccess {
}
final DataAccessAddOn addOn = findAddOnforField(field);
if (addOn != null && !addOn.canInsert(field)) {
if (addOn.isInsertAsync(field)) {
if (addOn.isUpdateAsync(field)) {
final List<TransmitKey> transmitKey = options.get(TransmitKey.class);
if (transmitKey.size() != 1) {
throw new DataAccessException(
@ -1242,6 +1242,9 @@ public class DBAccessSQL extends DBAccess {
addOn.insertData(this, ps, field, data, iii);
}
}
for (final LazyGetter action : asyncActions) {
action.doRequest();
}
condition.injectQuery(this, ps, iii);
final int out = ps.executeUpdate();
return out;
@ -1250,9 +1253,6 @@ public class DBAccessSQL extends DBAccess {
} catch (final SQLException ex) {
ex.printStackTrace();
}
for (final LazyGetter action : asyncActions) {
action.doRequest();
}
return 0L;
}

View File

@ -475,7 +475,11 @@ public class AddOnManyToMany implements DataAccessAddOn {
if (remoteKey == null) {
throw new DataAccessException("Try to insert remote key with null value");
}
insertElements.add(new LinkTableGeneric(localKey, remoteKey));
if (linkTable.first) {
insertElements.add(new LinkTableGeneric(localKey, remoteKey));
} else {
insertElements.add(new LinkTableGeneric(remoteKey, localKey));
}
}
if (insertElements.size() == 0) {
LOGGER.warn("Insert multiple link without any value (may have null in the list): {}", dataCasted);