私のエンティティクラス
@Entity
@Table(catalog = "", schema = "MYIS")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Answers.findAll", query = "SELECT a FROM Answers a"),
@NamedQuery(name = "Answers.findByAid", query = "SELECT a FROM Answers a WHERE a.aid = :aid"),
@NamedQuery(name ="Anaswers.findByqid", query ="SELECT a FROM Answers a WHERE a.answerQid.qid = :x"),
@NamedQuery(name = "Answers.findByAnsValue", query = "SELECT a FROM Answers a WHERE a.ansValue = :ansValue"),
@NamedQuery(name = "Answers.findByAnsDate", query = "SELECT a FROM Answers a WHERE a.ansDate = :ansDate")})
public class Answers implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Column(nullable = false)
private Integer aid;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 4000)
@Column(name = "ANS_VALUE", nullable = false, length = 4000)
private String ansValue;
@Basic(optional = false)
@NotNull
@Column(name = "ANS_DATE", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date ansDate;
@JoinColumn(name = "A_USERID", referencedColumnName = "USERID", nullable = false)
@ManyToOne(optional = false)
private Users aUserid;
@JoinColumn(name = "ANSWER_QID", referencedColumnName = "QID", nullable = false)
@ManyToOne(optional = false)
private Questions answerQid;
@JoinColumn(name = "A_GROUPID", referencedColumnName = "GID", nullable = false)
@ManyToOne(optional = false)
private Groups aGroupid;
public Answers() {
}
public Answers(Integer aid) {
this.aid = aid;
}
public Answers(Integer aid, String ansValue, Date ansDate) {
this.aid = aid;
this.ansValue = ansValue;
this.ansDate = ansDate;
}
public Integer getAid() {
return aid;
}
public void setAid(Integer aid) {
this.aid = aid;
}
public String getAnsValue() {
return ansValue;
}
public void setAnsValue(String ansValue) {
this.ansValue = ansValue;
}
public Date getAnsDate() {
return ansDate;
}
public void setAnsDate(Date ansDate) {
this.ansDate = ansDate;
}
public Users getAUserid() {
return aUserid;
}
public void setAUserid(Users aUserid) {
this.aUserid = aUserid;
}
public Questions getAnswerQid() {
return answerQid;
}
public void setAnswerQid(Questions answerQid) {
this.answerQid = answerQid;
}
public Groups getAGroupid() {
return aGroupid;
}
public void setAGroupid(Groups aGroupid) {
this.aGroupid = aGroupid;
}
@Override
public int hashCode() {
int hash = 0;
hash += (aid != null ? aid.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Answers)) {
return false;
}
Answers other = (Answers) object;
if ((this.aid == null && other.aid != null) || (this.aid != null && !this.aid.equals(other.aid))) {
return false;
}
return true;
}
@Override
public String toString() {
return "com.entity.Answers[ aid=" + aid + " ]";
}
}
私のセッションファサード
import com.entity.Answers;
import com.entity.Groups;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
/**
*
* @author krishna teja
*/
@Stateless
public class AnswersFacade extends AbstractFacade<Answers> implements AnswersFacadeLocal {
@PersistenceContext(unitName = "My_communityPU")
private EntityManager em;
@Override
protected EntityManager getEntityManager() {
return em;
}
public AnswersFacade() {
super(Answers.class);
}
public List<Answers> getdataByQid(Long qid){
Query query=em.createNamedQuery("Answers.findByqid");
query.setParameter(1, qid);
List<Answers> a =query.getResultList();
return a;
}
}
私のマネージドBean
@PostConstruct
public void init(){
questions = questionsFacade.findAll();
ansList = answersFacade.getdataByQid(g);
}
次の例外が発生しています
at com.ejb.AnswersFacade.getdataByQid(AnswersFacade.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
外部キー属性 answerQid の名前付きクエリを作成し、sessionfacade でメソッドを作成し、マネージド Bean でそれにアクセスしようとしましたが、デフォルトのメソッドは完全に機能しますが、クエリのメソッドが機能しません助けてください