我有以下带有内部连接的 MySQL 更新查询:
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'
这是我的国家地图课
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 类
@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;
我如何用休眠语言编写相同的查询。任何人都可以帮助我。我已经尝试了很多,但我做不到。
谢谢