Hello.
repository.save(objectA) is too slow due to @IndexingDependency(derivedFrom).
I watch that during save it does always select from the objectB. Removing them works fine.
How can i skip this problem ?
@Indexed(index = "idx_name")
@Table(name = "tableName")
public class ObjectΑ {
@Id
@Column(name = "id", nullable = false, precision = 18)
@ScaledNumberField(decimalScale = 0, sortable = Sortable.YES)
private BigInteger id;
@OneToMany(mappedBy = "objectA", cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
@IndexedEmbedded(structure = ObjectStructure.NESTED, includePaths = {""relObjectb.id", "fielda", "fieldb", ...})
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
private List<ObjectB> bList = new ArrayList<>();
.
.
.
@Transient
@IndexingDependency(derivedFrom = @ObjectPath({
@PropertyValue(propertyName = "bList"),
@PropertyValue(propertyName = "debit")
}))
@ScaledNumberField(decimalScale = 2, sortable = Sortable.YES)
private BigDecimal totalObjectBDebit;
public BigDecimal getTotalObjectBDebit() {
BigDecimal objectBDebit = BigDecimal.ZERO;
if (CollectionUtils.isNotNullOrEmpty(bList)) {
for (final ObjectΒ b: bList) {
objectBDebit = objectBDebit .add(b.getDebit() != null ? b.getDebit() : BigDecimal.ZERO);
}
}
return objectBDebit;
}
@Transient
@IndexingDependency(derivedFrom = @ObjectPath({
@PropertyValue(propertyName = "bList"),
@PropertyValue(propertyName = "debit")
}))
@ScaledNumberField(decimalScale = 2, sortable = Sortable.YES)
private BigDecimal totalObjectΒCredit;
public BigDecimal getTotalObjectΒCredit() {
BigDecimal objectΒCredit = BigDecimal.ZERO;
if (CollectionUtils.isNotNullOrEmpty(bList)) {
for (final ObjectΒ b: bList) {
objectΒCredit = objectΒCredit .add(b.getCredit() != null ? b.getCredit() : BigDecimal.ZERO);
}
}
return objectΒCredit ;
}
@Transient
@IndexingDependency(derivedFrom = @ObjectPath({
@PropertyValue(propertyName = "bList"),
@PropertyValue(propertyName = "totalamount")
}))
@ScaledNumberField(decimalScale = 2, sortable = Sortable.YES)
private BigDecimal totalObjectΒTotalamount;
public BigDecimal getTotalObjectΒTotalamount() {
BigDecimal objectΒTotalamount = BigDecimal.ZERO;
if (CollectionUtils.isNotNullOrEmpty(bList)) {
for (final ObjectΒ b: bList) {
objectΒTotalamount = objectΒTotalamount .add(b.getTotalamount() != null ? b.getTotalamount() : BigDecimal.ZERO);
}
}
return objectΒTotalamount ;
}
}
ι expected these fields to affect the index only when the field in the 2nd propertyvalue is changed(debit, credit or totalamount), so to execute select * from objectB only in this case and not in every save of the objectA