@Entity
public class TransactionInfo {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne
@JoinColumn(name="txnRequestId")
private TransactionRequest txnRequest;
..
}
I would like to do a bulk update on this table using the txnRequestId id field (which is mapped with id field of TransactionRequest table)
With my limited knowledge on HQL so far, I tried this query with tr.txnRequest.id field to compare id of TransactionRequest table -
@Repository
public interface TransactionInfoRepository extends JpaRepository<TransactionInfo, Long>, JpaSpecificationExecutor<TransactionInfo> {
@Transactional
@Modifying
@Query("UPDATE TransactionInfo as tr SET status=?2 WHERE tr.status=?1 and tr.txnRequest.id in (?3)")
int updateStatusToRequestedByTxnReqId(Enum.TransactionStatus oldStatus, Enum.TransactionStatus newStatus, List<Long> trIds);
Exception -
Unexpected errororg.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [UPDATE com.project.model.TransactionInfo as tr SET status=?2 WHERE tr.status=?1 and tr.txnRequest.id in (?3)]; nested exception is java.lang.IllegalStateException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for
DML operations [UPDATE com.project.model.TransactionInfo as tr SET status=?2 WHERE tr.status=?1 and tr.txnRequest.id in (?3)]
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [UPDATE com.project.model.TransactionInfo as tr SET status=?2 WHERE tr.stat
us=?1 and tr.txnRequest.id in (?3)]; nested exception is java.lang.IllegalStateException: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [UPDATE com.project.model.TransactionInfo as
tr SET status=?2 WHERE tr.status=?1 and tr.txnRequest.id in (?3)]
I also tried with tr.txnRequestId but got -
org.hibernate.QueryException: could not resolve property: txnRequestId of: com.project.model.TransactionInfo
I would appreciate a documentation link or link to this chapter in Hibernate, as I could not reach upto studying these things yet and hence do not know what to search for.