lundi 8 juin 2015

J2EE JPA and class inheritance - Unknown column 'field list'

Hi I am little bit desperate about one issue i have been struggling with. As a practise I am trying to build very simple ebanking app. So one table is called products (str productName, str descr), other is savingsAccounts(int accountNo, int clientNo, int balance). I have two classes:

savingsAccount.java

@Entity
@Table(name = "savingsAccounts")  
@NamedQueries({  
@NamedQuery(name = "savingsAccount.findAll", query = "SELECT s FROM savingsAccount s"),
@NamedQuery(name = "savingsAccount.findByClientNo", query = "SELECT s FROM savingsAccount s WHERE s.clientNo = :p_clientNo")
})

public class savingsAccount extends product implements Serializable {
@Id
@Basic(optional = false)
@NotNull  
@Column(name = "accountNo")  
private Integer accountNo;  
@Basic(optional = false)  
@NotNull  
@Column(name = "clientNo")  
private Integer clientNo;  
@Basic(optional = false)  
@NotNull  
@Column(name = "balance")  
private double balance;

//getters and setters nad constructorscode here

product.java

@Entity  
@Table(name = "products")  
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)  
public class product implements Serializable {
@Id  
@Basic(optional = false)  
@NotNull  
@Size(min = 1, max = 20)  
@Column(name = "productName")  
public String productName;  

@Basic(optional = false)
@NotNull
@Size(min = 1, max = 100)
@Column(name = "descr")
private String descr;

//gettes and setters and contructors

but when i run the namedquery savingsAccount.findByClientNo it gives me this statement:

SELECT accountNo, productName, balance, clientNo, descr FROM savingsAccounts WHERE (clientNo = ?)

it gives me this error: Internal Exception:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'descr' in 'field list'

I somehow "feel" that the issue is that there is no field called descr in savingsAccount table but i really do not know how to make it work... Thanks to all of you for help.

Aucun commentaire:

Enregistrer un commentaire