我一直在休眠状态下查询更新实体的状态。这种称为PaymentRequestLink的实体与另一个称为Extraparameters的实体具有一对多关系
PaymentRequestType.java:
<html>
<head>
<script type="text/javascript" src="pic.js"></script>
<link rel="stylesheet" href="pic.css">
</head>
<body class="desz">
<div class="desz">
<div class="deghsz cent">
<button class="Bleft" onclick="RanImg()">Random all</button>
<button class="Bcent" onclick="Toggle1()">Toggle</button>
<button class="Bright" onclick="RanImg1()">Random</button>
</div>
<div class="deghsz cent">
<button class="Bleft" onclick="Toggle2()">Toggle</button>
<button class="Bright" onclick="RanImg2()">Random</button>
</div></div>
<div class="desz">
<div id="L1" class="dehsz left cent">
<img id="rando" class="pic" src="images/space.jpg" />
</div>
<div id="R1" class="dehsz right cent">
<img id="rando2" class="pic" src="images/space2.jpg" />
</div></div>
</body>
</html>
ExtraParameter.java:
@Entity
@Table(name="payment_link")
public class PaymentRequestLink {
private Map<String, ExtraParameter<E>> extraParameters;
@Fetch(FetchMode.SELECT)
@ElementCollection(fetch=FetchType.EAGER)
@CollectionTable(name="extraparameter_payment_link",
schema=BaseEntity.DATABASE_SCHEMA, joinColumns=@JoinColumn(name="extraparameter_payment_link_id"))
@MapKeyColumn(name = "name", length=64, nullable = false)
public Map<String, ExtraParameter<String>> getExtraParameters() {
return extraParameters;
}
这是extraparameter_payment_link表的数据示例:
@Embeddable
public class ExtraParameter<T extends Serializable> implements Serializable {
//...
@Column(name="extra_type", length=64, nullable=false)
@NotNull
public String getType() {
return type;
}
@Column(name="extra_value", length=255, nullable=false)
@NotNull
public T getValue() {
return value;
}
我要进行的查询是,当存储在Extraparameters中的到期日期是当前日期之前的日期时,将PaymentRequestLink的状态更新为EXPIRED。 这是我现在拥有的查询:
extraparameter_payment_link_id extra_type extra_value name
1 java.sql.Date 2019-01-01 EXPIRATION_DATE
我遇到的例外是:
String stateSentence = "AND state <> '";
String sqlUpdateLinkDetailed = "UPDATE PaymentRequestLink ld SET state='EXPIRED' " +
"WHERE extraParameters.EXPIRATION_DATE.value <= ? " +
stateSentence + PaymentRequestLinkState.PAID;
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 1);
Timestamp now = new Timestamp(calendar.getTimeInMillis());
hibernateTemplate.bulkUpdate(sqlUpdateLinkDetailed, now);
有人可以帮我吗?
答案 0 :(得分:4)