Hibernate update query with innerjoin
hibernate, hibernate-criteria, hibernate-mapping, inner-join
Solution
You can't. HQL update queries can't have joins. See the documentation:
Some points to note:
- [...]
- No joins, either implicit or explicit, can be specified in a bulk HQL query.
Problem
I have the following MySQL update query with inner join: ``` UPDATE Country AS c INNER JOIN State s ON c.CountryID = s.CountryID INNER JOIN City cy On s.StateID = cy.StateID SET c.Active='Y', s.Active='Y',cy.Active='Y' WHERE c.CountryID='12' ``` Here is my country mapping class ``` enter code here @Entity @Table(name = "Country") public class Country { public Country() { } @Id @Column(name = "CountryID") private String countryID; @OneToMany(fetch = FetchType.LAZY, mappedBy = "country") private Set<State> state = new HashSet<State>(0); @Column(name = "CountryName") private String countryName; } ``` Mpping class for State ``` @Entity @Table(name = "State") public class State { public State() { } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "countryID", nullable = false) private Country country; public Country getCountry() { return country; } public void setCountry(Country country) { this.country = country; } @Id @Column(name = "StateID") private String stateID; @Column(name = "CountryID") private String countryID; @Column(name = "StateName") private String stateName; ``` How can i write the same query in hibernatye language.can any one please help me. i have tried a lot but i can't make it. Thanks