次のテーブルがありますブランド(brand_id、brand_name)Webサイト(website_id、brand_idなど...)
Web サイトに多くのブランドを含めることができる場所。以下は、私のブランドとウェブサイトのクラスのコピーです。
public class Website implements java.io.Serializable {
private int websiteId;
private WebsiteType websiteType;
private Brand brand;
private Serializable websiteTradingName;
private Serializable websiteDomain;
private Serializable analyticsId;
private String countryId;
private Boolean websiteStatus;
private Serializable websiteHomeFolder;
private Serializable websitePrivacyPolicy;
private Set cmsPages = new HashSet(0);
private Set websiteDomainNames = new HashSet(0);
private Set cmsLogins = new HashSet(0);
private Set websiteImages = new HashSet(0);
@Id
@Column(name="website_id", unique=true, nullable=false)
public int getWebsiteId() {
return this.websiteId;
}
public void setWebsiteId(int websiteId) {
this.websiteId = websiteId;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="website_type_id", nullable=false)
public WebsiteType getWebsiteType() {
return this.websiteType;
}
public void setWebsiteType(WebsiteType websiteType) {
this.websiteType = websiteType;
}
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="brand_id", nullable=false)
public Brand getBrand() {
return this.brand;
}
public void setBrand(Brand brand) {
this.brand = brand;
}
@Column(name="website_trading_name", nullable=false)
public Serializable getWebsiteTradingName() {
return this.websiteTradingName;
}
public void setWebsiteTradingName(Serializable websiteTradingName) {
this.websiteTradingName = websiteTradingName;
}
@Column(name="website_domain", nullable=false)
public Serializable getWebsiteDomain() {
return this.websiteDomain;
}
public void setWebsiteDomain(Serializable websiteDomain) {
this.websiteDomain = websiteDomain;
}
@Column(name="analytics_id")
public Serializable getAnalyticsId() {
return this.analyticsId;
}
public void setAnalyticsId(Serializable analyticsId) {
this.analyticsId = analyticsId;
}
@Column(name="country_id", nullable=false, length=2)
public String getCountryId() {
return this.countryId;
}
public void setCountryId(String countryId) {
this.countryId = countryId;
}
@Column(name="website_status")
public Boolean getWebsiteStatus() {
return this.websiteStatus;
}
public void setWebsiteStatus(Boolean websiteStatus) {
this.websiteStatus = websiteStatus;
}
@Column(name="website_home_folder")
public Serializable getWebsiteHomeFolder() {
return this.websiteHomeFolder;
}
public void setWebsiteHomeFolder(Serializable websiteHomeFolder) {
this.websiteHomeFolder = websiteHomeFolder;
}
@Column(name="website_privacy_policy")
public Serializable getWebsitePrivacyPolicy() {
return this.websitePrivacyPolicy;
}
public void setWebsitePrivacyPolicy(Serializable websitePrivacyPolicy) {
this.websitePrivacyPolicy = websitePrivacyPolicy;
}
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="website")
public Set getCmsPages() {
return this.cmsPages;
}
public void setCmsPages(Set cmsPages) {
this.cmsPages = cmsPages;
}
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="website")
public Set getWebsiteDomainNames() {
return this.websiteDomainNames;
}
public void setWebsiteDomainNames(Set websiteDomainNames) {
this.websiteDomainNames = websiteDomainNames;
}
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="website")
public Set getCmsLogins() {
return this.cmsLogins;
}
public void setCmsLogins(Set cmsLogins) {
this.cmsLogins = cmsLogins;
}
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="website")
public Set getWebsiteImages() {
return this.websiteImages;
}
public void setWebsiteImages(Set websiteImages) {
this.websiteImages = websiteImages;
}
}
public class Brand implements java.io.Serializable {
private static final long serialVersionUID = 1L;
private int brandId;
private String brandName;
private Set websites = new HashSet(0);
public Brand() {
}
public Brand(int brandId, String brandName) {
this.brandId = brandId;
this.brandName = brandName;
}
public Brand(int brandId, String brandName, Set websites) {
this.brandId = brandId;
this.brandName = brandName;
this.websites = websites;
}
@Id
@Column(name="brand_id", unique=true, nullable=false)
public int getBrandId() {
return this.brandId;
}
public void setBrandId(int brandId) {
this.brandId = brandId;
}
@Column(name="brand_name", nullable=false, length=50)
public String getBrandName() {
return this.brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="brand")
public Set getWebsites() {
return this.websites;
}
public void setWebsites(Set websites) {
this.websites = websites;
}
}
私がやりたいのは、「brand_id = X のウェブサイトから * を選択する」ことです。
私はHibernateが初めてで、これを行う方法がわかりません。誰か助けてください。ありがとう