I got [42000] You have an error in your SQL syntax error when I execute the HQL below:
Code:
update Status set result=18 where (userByUserId.userName like 'administrator')
And this is the corresponding SQL:
Code:
update
status cross
join
set
result=18
where
userName like 'administrator'
The results I am getting are incorrect.
But another similar query is in working order:
Code:
select count(*) from Status where (userByUserId.userName like 'administrator')
the corresponding SQL:
Code:
select
count(*) as col_0_0_
from
status status0_ cross
join
user user1_
where
status0_.userId=user1_.userId
and (
user1_.userName like 'administrator'
)
Does anyone knows what happened?
Here is the code(partly):
Status.java
Code:
@Table(name = "status")
@Entity
@KeyField("statusId")
public class Status implements Serializable {
private Integer result;
@Column(name = "result", nullable = false, insertable = true, updatable = true
, length = 10, precision = 0)
@Basic
public Integer getResult() {
return result;
}
private Integer userId;
@Column(name = "userId", nullable = false, insertable = true, updatable = true
, length = 10, precision = 0)
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
private User userByUserId;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "userId", referencedColumnName = "userId", nullable = false,
insertable = false, updatable = false)
public User getUserByUserId() {
return userByUserId;
}
}
User.java
Code:
@Table(name = "user")
@Entity
@KeyField("userId")
public class User implements Serializable {
private String userName;
@Column(name = "userName", nullable = false, insertable = true, updatable = true, length = 24,
precision = 0, unique = true)
@Basic
public String getUserName() {
return userName;
}
private Collection<Status> statusesByUserId;
@OneToMany(mappedBy = "userByUserId", cascade = CascadeType.ALL)
public Collection<Status> getStatusesByUserId() {
return statusesByUserId;
}
}