I try to use HQL query:
Session session = sessionFactory.getCurrentSession(); Query query = session.createQuery("update AlgorithmScript set isActive = false where user.loginName=:userName"); query.setParameter("userName", userName); query.executeUpdate(); but Hibernate generates invalid SQL query:
Hibernate: update algorithmfight_checkers_db.algorithmscripts, set IsActive=0 where LoginName=? Help me.
EDIT1 (Entity class for AlgorithmScript): This code was generated by Hibernate Tools plugin====================================================
@Entity @Table(name = "algorithmscripts", catalog = "algorithmfight_checkers_db") public class AlgorithmScript implements java.io.Serializable { private int algorithmScriptId; private User user; private String fileName; private String content; private Date uploadedDate; private boolean isActive; private boolean isDeleted; public AlgorithmScript() { } public AlgorithmScript(int algorithmScriptId, User user, String fileName, String content, Date uploadedDate, boolean isActive, boolean isDeleted) { this.algorithmScriptId = algorithmScriptId; this.user = user; this.fileName = fileName; this.content = content; this.uploadedDate = uploadedDate; this.isActive = isActive; this.isDeleted = isDeleted; } @Id @Column(name = "AlgorithmScriptId", unique = true, nullable = false) public int getAlgorithmScriptId() { return this.algorithmScriptId; } public void setAlgorithmScriptId(int algorithmScriptId) { this.algorithmScriptId = algorithmScriptId; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "UserId", nullable = false) public User getUser() { return this.user; } public void setUser(User user) { this.user = user; } @Column(name = "FileName", nullable = false) public String getFileName() { return this.fileName; } public void setFileName(String fileName) { this.fileName = fileName; } @Column(name = "Content", nullable = false, length = 65535) public String getContent() { return this.content; } public void setContent(String content) { this.content = content; } @Temporal(TemporalType.TIMESTAMP) @Column(name = "UploadedDate", nullable = false, length = 19) public Date getUploadedDate() { return this.uploadedDate; } public void setUploadedDate(Date uploadedDate) { this.uploadedDate = uploadedDate; } @Column(name = "IsActive", nullable = false) public boolean isIsActive() { return this.isActive; } public void setIsActive(boolean isActive) { this.isActive = isActive; } @Column(name = "IsDeleted", nullable = false) public boolean isIsDeleted() { return this.isDeleted; } public void setIsDeleted(boolean isDeleted) { this.isDeleted = isDeleted; } }