hibernate的级联:可不可以实现一个实体自身级联它自己啊?
解决方案 »
- 有人用过新浪微博oauth第3方授权么????????????????????????????
- apache+tomcat 集群环境下,DWR生成的JS文件的路径问题?
- SSH配置问题!急急!!!
- 采购管理。。。。不会。。
- 初次接触socket,错误诊断!help me!
- 急需,请各位帮忙!
- 问大家一个弱智的问题。
- 公司技术员写的jar竟含源代码,怎末回事?
- Exception in thread "main" java.lang.NoClassDefFoundError:test 是怎么回事!
- spring hibernate 用注解生成表,怎么保存主从信息
- 那位高手知道怎么用JAVA来实现本地连接的数据包发送和接收数量?
- 关于代码的重构问题!!设计模式~原则!!谢谢大家!!!!
.
.
.
private City anotherCity;
.
.
.
@ManyToOne
@JionColunm(name='anothercityid',referencedColumnName='id')
public City getAnotherCity() {
return anotherCity;
}
.
.
}
这是pojo:
import java.util.Set;import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;@Entity
@Table(name ="t_city")
public class City { @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int cityId;
private String name;
@OneToMany
@JoinColumn(name = "cityFId")
private Set<City> cities; @ManyToOne
@JoinColumn(name = "cityFId")
private City city;
public int getCityId() {
return cityId;
} public void setCityId(int cityId) {
this.cityId = cityId;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public Set<City> getCities() {
return cities;
} public void setCities(Set<City> cities) {
this.cities = cities;
}}