私は休止状態でjoinを実行しようとしています。私はstruts2を使用しています。 私はannotaionsを使用している休止状態で作業しています。今、私は2つのテーブル間の結合を実行することができません。私の最初のテーブルは、pidとemail.Secondテーブルを含む "studentprojects"は、pid、名前、説明を含む "initialprojectdetials"です...同様にいくつかの他のフィールド。第1のテーブルのpidの周りで結合を実行することによって第2のテーブルのデータを更新する。annotaionでhibernateに参加する
String hql="from InitialProjectDTO I join I.projectId S where I.projectId=:id";
Query query=session.createQuery(hql);
query.setParameter("id", id);
mail =query.list();
メールがInitialProjectDTOのArrayListには、次のとおりです。このため は、このクエリを使用しています。 そして、私のInitialProjectDTOは次のとおりです。
package edu.pma.dto;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name="initialprojectdetail")
public class InitialProjectDTO {
@Id
@Column(name="projectId")
@OneToMany(cascade=CascadeType.ALL)
@JoinTable(name="studentprojects",[email protected](name="projectId"))
int projectId;
@Column(name="name")
String name;
@Column(name="description")
String description;
@Column(name="technology")
String technology;
@Column(name="guide")
String guide;
@Column(name="duration")
int duration;
@Column(name="status")
String status;
@Column(name="report")
String report;
public String getReport() {
return report;
}
public void setReport(String report) {
this.report = report;
}
public int getProjectId() {
return projectId;
}
public void setProjectId(int projectId) {
this.projectId = projectId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getTechnology() {
return technology;
}
public void setTechnology(String technology) {
this.technology = technology;
}
public String getGuide() {
return guide;
}
public void setGuide(String guide) {
this.guide = guide;
}
public int getDuration() {
return duration;
}
public void setDuration(int duration) {
this.duration = duration;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
私SudentProjectDTOは次のとおりです。これは私が取得していますエラーです
package edu.pma.dto;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="studentprojects")
public class StudentProjectDTO {
public int getProjectId() {
return projectId;
}
public void setProjectId(int projectId) {
this.projectId = projectId;
}
@Id
@Column(name="email")
String email;
@Column(name="projectId")
int projectId;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
:
Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: edu.pma.dto.InitialProjectDTO.projectId
Method "execute" failed for object [email protected]
File: org/hibernate/cfg/annotations/CollectionBinder.java
おかげのようなものにshoud。しかし、それは私にとってはうまくいきませんでした。私は注釈を使用しているので、私はDTOクラスの中で、部分DBテーブルであるものを除き、余分なフィールドを追加することはできません。したがって、それは私にsesdion工場を建設しないという誤りを与えています。 –