我的程序有些困难。我想要的只是从表中获取一些具有这种简单结构的对象:
mysql> describe tb_rasa;
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| nazwa | varchar(50) | YES | | NULL | |
| symbol | varchar(4) | NO | UNI | NULL | |
+--------+-------------+------+-----+---------+----------------+
在我的豆类中,我有:
@PostConstruct
public void init() {
rasa = rasaEJB.wyswietlRase(1);
}
在 RasaEJB 中:
public RasaSl wyswietlRase(Integer id) {
System.out.println("RasaEJB.wyswietlRase(id)");
RasaSl rasa = rasaDao.find(id);
return rasa;
}
RasaSl 实体看起来像:
@Entity
@Table(name="tb_rasa")
public class RasaSl implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4682401385263402475L;
@Id
@Column(name="id")
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name="nazwa",columnDefinition="varchar(50)")
private String nazwa;
@Column(name="symbol", columnDefinition="varchar(4)")
private String symbol;
@OneToMany(mappedBy="rasaSl", cascade=CascadeType.PERSIST)
private List<RasaStatystyka> modyfikatory = new ArrayList<RasaStatystyka>();
public String getNazwa() {
return nazwa;
}
public void setNazwa(String nazwa) {
this.nazwa = nazwa;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public List<RasaStatystyka> getModyfikatory() {
return modyfikatory;
}
public void setModyfikatory(List<RasaStatystyka> modyfikatory) {
this.modyfikatory = modyfikatory;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
}
我完全知道什么会造成这个错误:
RasaEJB.wyswietlRase(id)
[EL Info]: 2013-08-29 16:45:18.207--ServerSession(1816969462)--EclipseLink, version: Eclipse Persistence Services - 2.5.0.v20130507-3faac2b
[EL Info]: 2013-08-29 16:45:18.588--ServerSession(1816969462)--file:/D:/usr/java/moje/system/.metadata/.plugins/org.eclipse.wst.server.core/tmp4/wtpwebapps/EclipseJPA2-war/WEB-INF/lib/EclipseJPA2-jpa-0.01.jar_persistenceUnit login successful
[EL Warning]: 2013-08-29 16:45:18.688--UnitOfWork(1358566974)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'id' in 'field list'
Error Code: 1054
Call: SELECT id, nazwa, symbol FROM tb_rasa WHERE (id = ?)
bind => [1 parameter bound]
Query: ReadObjectQuery(name="readRasaSl" referenceClass=RasaSl sql="SELECT id, nazwa, symbol FROM tb_rasa WHERE (id = ?)")
请帮忙。