我有一個這樣的實體:JPQL更新查詢
@Entity
@Table(name = "QUESTION_GROUP_TEXT")
@NamedQueries({
@NamedQuery(
name = EntityUtils.NamedQuery.UPDATE_QUESTION_GROUP_TEXT,
query = "UPDATE QuestionGroupText T SET T.localizedText.content = :content WHERE T.generatedId = :generatedId")
})
public class QuestionGroupText implements Serializable {
@Column(name = "GENERATED_ID", nullable = false, unique = true)
private String generatedId = generateId();
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "LOCALIZED_TEXT_ID", nullable = false)
private LocalizedText localizedText;
//Getters and setters
}
這個查詢:UPDATE QuestionGroupText T SET T.localizedText.content = :content WHERE T.generatedId = :generatedId
不起作用,它拋出:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'set CONTENT='Question Label' where GENERATED_ID='AD78F9B5E2A146D9AB9D94096DA835B' at line 1
必須有與查詢的這部分不對勁: T.localizedText.content
,有什麼辦法可以改變它來完成這項工作嗎?