@Entity
public class TransactionInfo {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne
@JoinColumn(name="txnRequestId")
private TransactionRequest txnRequest;
..
}
Я хотел бы выполнить массовое обновление этой таблицы, используя поле id txnRequestId (которое сопоставлено с полем id таблицы TransactionRequest)
С моими ограниченными знаниями о HQL до сих пор я пробовал этот запрос с полем tr.txnRequest.id для сравнения идентификатора таблицы TransactionRequest -
@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)]
Я также пробовал с tr.txnRequestId, но получил -
org.hibernate.QueryException: could not resolve property: txnRequestId of: com.project.model.TransactionInfo
Я был бы признателен за ссылку на документацию или ссылку на эту главу в Hibernate, так как я еще не смог дойти до изучения этих вещей и, следовательно, не знаю, что искать.