-2

I have a class like below:

import lombok.Getter;
import lombok.Setter;
import org.framework.model.core.baseInfo.SubSystemType;

import javax.persistence.Entity;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;


@Entity
@Table(name = "CORE_POWER_TYPE_DOCUMENT")
@PrimaryKeyJoinColumn(name = "Base_Power_Type_Id")
@Getter
@Setter
public class StoragePowerType extends BasePowerType {

    @Override
    public SubSystemType getsystemType() {
        return SubSystemType.storing;
    }

}

and below exception id throwed:

"****counld not set field value [org.model.core.power.type.StoragePowerType@203cb33d] value by reflection ****"

Do you know what is the problem??

developers_
  • 31
  • 2
  • 7

1 Answers1

0

Most likely some property inside BasePowerType is declared as private, with no getter and setter.

Each property of JPA entity must either be public or have methods get<PropertyName>() and set<PropertyName>() defined. Otherwise the framework you are using (Hibernate?) will not be able to access the property. So use either:

public Long id;

Or:

private Long id;

public Long getId() { return id; }
public void setId(Long value) { id = value; }

Try to follow guidelines from here: Create the perfect JPA entity [closed] .

Šimon Kocúrek
  • 1,591
  • 1
  • 12
  • 22