BeanFieldGroup error

I am using JPA to pull data from the database to an entity bean. Then using the entity bean, I want to map it to my UI form. Here’s the code below.

EntityManagerFactory emFactory = Persistence
.createEntityManagerFactory(“AAPTimize”);

    em = emFactory.createEntityManager();
    BeanItem<EntityAccount> item = new BeanItem<EntityAccount>(em.find(
            EntityAccount.class, new Long(6)));

    BeanFieldGroup<EntityAccount> binder = new BeanFieldGroup<EntityAccount>(
            EntityAccount.class);
    binder.setItemDataSource(item);
    
    binder.bindMemberFields(this);
    binder.bind(_nameField, "altername_name");

    this._saveButton.addClickListener(e -> e.getButton().setCaption(
            "Save record"));

}

/**

  • The persistent class for the entity_account database table.

*/
@Entity
@Table(name=“entity_account”)
@NamedQuery(name=“EntityAccount.findAll”, query=“SELECT e FROM EntityAccount e”)
public class EntityAccount implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;

@Column(name="alternate_name")
private String alternateName;

@Column(name="created_by")
private String createdBy;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="created_time")
private Date createdTime;

@Temporal(TemporalType.DATE)
@Column(name="effective_date")
private Date effectiveDate;

@Column(name="entity_id")
private java.math.BigInteger entityId;

private String fein;

@Temporal(TemporalType.DATE)
@Column(name="obsolete_date")
private Date obsoleteDate;

@Column(name="short_name")
private String shortName;

@Column(name="updated_by")
private String updatedBy;

@Temporal(TemporalType.TIMESTAMP)
@Column(name="updated_time")
private Date updatedTime;

public EntityAccount() {
}

public Long getId() {
    return this.id;
}

public void setId(Long id) {
    this.id = id;
}

public String getAlternateName() {
    return this.alternateName;
}

public void setAlternateName(String alternateName) {
    this.alternateName = alternateName;
}

public String getCreatedBy() {
    return this.createdBy;
}

public void setCreatedBy(String createdBy) {
    this.createdBy = createdBy;
}

public Date getCreatedTime() {
    return this.createdTime;
}

public void setCreatedTime(Date createdTime) {
    this.createdTime = createdTime;
}

public Date getEffectiveDate() {
    return this.effectiveDate;
}

public void setEffectiveDate(Date effectiveDate) {
    this.effectiveDate = effectiveDate;
}

public java.math.BigInteger getEntityId() {
    return this.entityId;
}

public void setEntityId(java.math.BigInteger entityId) {
    this.entityId = entityId;
}

public String getFein() {
    return this.fein;
}

public void setFein(String fein) {
    this.fein = fein;
}

public Date getObsoleteDate() {
    return this.obsoleteDate;
}

public void setObsoleteDate(Date obsoleteDate) {
    this.obsoleteDate = obsoleteDate;
}

public String getShortName() {
    return this.shortName;
}

public void setShortName(String shortName) {
    this.shortName = shortName;
}

public String getUpdatedBy() {
    return this.updatedBy;
}

public void setUpdatedBy(String updatedBy) {
    this.updatedBy = updatedBy;
}

public Date getUpdatedTime() {
    return this.updatedTime;
}

public void setUpdatedTime(Date updatedTime) {
    this.updatedTime = updatedTime;
}

}

When I execute the code, I get “Bean property ‘altername_name’ not found”. What am I doing wrong?

Thanks.

You should map it against the field name, which is “alternateName”, and not against the database column name.

 binder.bind(_nameField, "alternateName");

Thanks…that was it.