执行executeUpdate时发生事务挂起

时间:2018-07-09 13:42:59

标签: java jpa

我正在尝试执行更新方法。当我尝试执行查询时,将被触发,但是此后什么也没有发生。事务挂起。我能知道是什么问题。哪个使此问题发生。

@Override
public Integer updateIncrementedSequenceNumber(SequenceNumber sequenceNumber) {
    CriteriaBuilder builder = manager.getCriteriaBuilder();
    CriteriaUpdate<SequenceNumber> criteriaQuery = builder.createCriteriaUpdate(SequenceNumber.class);
    Root<SequenceNumber> root = criteriaQuery.from(SequenceNumber.class);

    criteriaQuery.set(root.get(SequenceNumber_.sequence), sequenceNumber.getSequence());

    criteriaQuery.where(builder.equal(root.get("sequenceId"), sequenceNumber.getSequenceId()));

    manager.createQuery(criteriaQuery).executeUpdate();
    return sequenceNumber.getSequenceId();

}




 @Entity
 @Table(name = "ref_data.sequence_num")
 public class SequenceNumber implements Serializable {


@Id
@Column(name = "sequence_id")
private Integer sequenceId;

@Column(name = "module_name")

private String moduleName;
@Column(name = "sequence_num")
private String sequence;

@Column(name = "updated_by")
private Integer updatedBy;
/**
 * updated time stamp
 */
@Column(name = "updated_on")
private Date updatedOn = new Date();

/**
 * @return the sequenceId
 */
public Integer getSequenceId() {
return sequenceId;
}

/**
 * @param sequenceId
 *            the sequenceId to set
 */
public void setSequenceId(Integer sequenceId) {
this.sequenceId = sequenceId;
}

/**
 * @return the moduleName
 */
public String getModuleName() {
return moduleName;
}

/**
 * @param moduleName
 *            the moduleName to set
 */
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}

/**
 * @return the sequence
 */
public String getSequence() {
return sequence;
}

/**
 * @param sequence
 *            the sequence to set
 */
public void setSequence(String sequence) {
this.sequence = sequence;
}

/**
 * @return the updatedBy
 */
public Integer getUpdatedBy() {
return updatedBy;
}

/**
 * @param updatedBy
 *            the updatedBy to set
 */
public void setUpdatedBy(Integer updatedBy) {
this.updatedBy = updatedBy;
}

/**
 * @return the updatedOn
 */
public Date getUpdatedOn() {
return updatedOn;
}

/**
 * @param updatedOn
 *            the updatedOn to set
 */
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}

}

在控制台中查询:

 Hibernate: update ref_data.sequence_num set module_name=?, sequence_num=?, updated_by=?, updated_on=? where sequence_id=?

之后什么也没发生。

0 个答案:

没有答案