Java 冬眠许多人加入
我对冬眠还不熟悉,我正在使用Spring。我有以下表格:Java 冬眠许多人加入,java,spring,hibernate,Java,Spring,Hibernate,我对冬眠还不熟悉,我正在使用Spring。我有以下表格: @Entity @Configurable public class Location { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long locationid; private String locationName; @ManyToOne private Site site; //getters se
@Entity
@Configurable
public class Location {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long locationid;
private String locationName;
@ManyToOne
private Site site;
//getters setters skipped
}
@Entity
@Configurable
public class Site {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long siteid;
private String siteName;
@ManyToOne
private Country country;
//getters setters skipped
}
@Entity
@Configurable
public class Country {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long countryid;
private String countryName;
@ManyToOne
private Region region;
//getters setters skipped
}
@Entity
@Configurable
public class Region {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long regionid;
private String regionName;
//getters setters skipped
}
public class Assets {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long assetId;
@ManyToOne
private Location location;
//getters setters skipped
}
我想根据地区提取所有资产。我该怎么做
如何使用区域->国家->站点->位置之间的关系,并提取相关记录?如何在不影响性能的情况下执行此操作
或者我应该重新设计表吗?您可以通过类资产中的@NamedQuery来完成它: 从断言a中选择a,其中a.location.site.contry.regin.reginName=:reginName 希望能有所帮助