JPA problem: Column override on fields

Today I was struggling with WLS 10.3, Workshop 10.3, JPA and Hibernate to get an Entity persistent to a Database. I got the following error:

I used the following code (which was acutally generated by Workshop!):

public class Werknemer implements Serializable {
 //default serial version id, required for serializable classes.
 private static final long serialVersionUID = 1L;
 private String persNummer; 
 private String emailInternet;
    public Werknemer() {

 @Column(name="email_internet", nullable=false, length=128)
 public String getEmailInternet() {
  return this.emailInternet;
 public void setEmailInternet(String emailInternet) {
  this.emailInternet = emailInternet;

As you can see from the error code the column name "email_internet" (as indicated by @Column) was not taken, but instead the "emailInternet" property was taken.
I could not find the problem, but the following helped. Move the JPA annotation above the private property, like this:

 @Column(name="email_internet", nullable=false, length=128)
 private String emailInternet;

This solved my problem, but not sure if this is a Hibernate, JPA bug?

1 comment:

  1. Hi,

    This is neither a bug in JPA nor in Hibernate.
    There are 2 access types : property access (via "getters") and field access (i.e "attribute") ; but you can't mix both in the same entity (in this case, the specification states that the behavior is undefined).

    Unless you explicitly specify the type by means of the javax.persistence.Access annotation. But the mix can be hard to debug... ;-)