eda*_*lij 7 hibernate inner-join hibernate-mapping hibernate-criteria
我有内部联接的以下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'
Run Code Online (Sandbox Code Playgroud)
这是我的国家地图类
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;
}
Run Code Online (Sandbox Code Playgroud)
国家的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;
Run Code Online (Sandbox Code Playgroud)
我如何在hibernatye语言中编写相同的查询.任何人请帮助我.我已经尝试了很多,但我做不到.
谢谢
归档时间: |
|
查看次数: |
5344 次 |
最近记录: |