锘??xml version="1.0" encoding="utf-8" standalone="yes"?>在线中文字幕资源,欧美一区二区综合,亚洲人一区二区http://www.aygfsteel.com/usherlight/category/37041.html澶╁鉤灞變笂鐧戒簯娉夛紝浜戣嚜鏃犲績姘磋嚜闂層備綍蹇呭鍐插北涓嬪幓錛屾洿娣繪嘗嫻悜浜洪棿錛?/description>zh-cnMon, 10 Aug 2009 08:07:48 GMTMon, 10 Aug 2009 08:07:48 GMT60- hibernate浣跨敤annotation鏉ュ鐞唎netomanyhttp://www.aygfsteel.com/usherlight/archive/2009/08/10/290529.html浜戣嚜鏃犲績姘磋嚜闂?/dc:creator>浜戣嚜鏃犲績姘磋嚜闂?/author>Mon, 10 Aug 2009 05:24:00 GMThttp://www.aygfsteel.com/usherlight/archive/2009/08/10/290529.htmlhttp://www.aygfsteel.com/usherlight/comments/290529.htmlhttp://www.aygfsteel.com/usherlight/archive/2009/08/10/290529.html#Feedback0http://www.aygfsteel.com/usherlight/comments/commentRss/290529.htmlhttp://www.aygfsteel.com/usherlight/services/trackbacks/290529.html
1. 鏁版嵁搴撶殑琛ㄧ粨鏋?br />
CREATE TABLE `software` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `version` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`publish_time` datetime NOT NULL,
`software_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
);
2. java鐨刢lass
---------------------------------------
Software.java
import java.util.LinkedHashSet;
import java.util.Set;
import javax.persistence.Entity;
@Entity
public class Software {
private Long id;
private String name;
private Set<Version> versions = new LinkedHashSet<Version>();
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@OneToMany(cascade = { CascadeType.ALL }, mappedBy="software")
@JoinColumn(name = "software_id")
@Fetch(FetchMode.SUBSELECT)
@OrderBy("id")
public Set<Version> getVersions() {
return version;
}
public void setVersions(Set<Version> Versions) {
this.versions = versions;
}
}
-----------------------------------------------------
Version.java
import java.util.Date;
import javax.persistence.Entity;
@Entity
public class Version{
private Long id;
private Date publishTime;
private Software software;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Date getPublishTime() {
return publishTime;
}
public void setPublishTime(Date publishTime) {
this.publishTime = publishTime;
}
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
@JoinColumn(name = "software_id")
public Software getSoftware() {
return software;
}
public void setSoftware(Software software) {
this.software = software;
}
}
3. 嫻嬭瘯浠g爜
Software software = new Software();
software.setName("Windows");
Version version = new Version;
version.setPublishTime(new Date());
version.setSoftware(software);
software.getVersions().add(version);
software.save();
hibernate浼氳嚜鍔ㄧ敓鎴愪袱鏉nsert璇彞錛屼竴鏉℃槸software鐨刬nsert璇彞錛屼竴鏉℃槸version鐨刬nsert璇彞銆?br />
鍚屾牱錛屽鏋滃垹闄oftware鐨勮瘽錛屼篃浼氱敓鎴愪袱鏉elete璇彞

]]> - Hibernate鍚姩鎶ラ敊cannot simultaneously fetch multiple bagshttp://www.aygfsteel.com/usherlight/archive/2008/12/30/249121.html浜戣嚜鏃犲績姘磋嚜闂?/dc:creator>浜戣嚜鏃犲績姘磋嚜闂?/author>Tue, 30 Dec 2008 05:03:00 GMThttp://www.aygfsteel.com/usherlight/archive/2008/12/30/249121.htmlhttp://www.aygfsteel.com/usherlight/comments/249121.htmlhttp://www.aygfsteel.com/usherlight/archive/2008/12/30/249121.html#Feedback0http://www.aygfsteel.com/usherlight/comments/commentRss/249121.htmlhttp://www.aygfsteel.com/usherlight/services/trackbacks/249121.html
Invocation of init method failed; nested exception is org.hibernate.HibernateException: cannot simultaneously fetch multiple bags
瑙e喅鏂規硶錛?br />
鍘婚櫎Annotation涓殑鎵鏈塅etchType="EAGAR"

]]>
主站蜘蛛池模板:
兖州市|
武乡县|
巧家县|
博爱县|
遂川县|
涞水县|
罗江县|
呼图壁县|
张家港市|
乌苏市|
观塘区|
双江|
鄂州市|
文山县|
河北区|
图片|
辽中县|
余江县|
九江县|
分宜县|
武夷山市|
西平县|
沙洋县|
盱眙县|
靖江市|
囊谦县|
咸阳市|
武隆县|
稷山县|
纳雍县|
通州市|
外汇|
南召县|
天祝|
延寿县|
永顺县|
都兰县|
临城县|
义马市|
巩义市|
金堂县|