3

I have Entity class with a helper method in it. like this..

@Entity
@Table(name = "MEMBER", schema = "APP_SCHEMA")
public class Member {

    private String id;
    private String externalMemberId;

    @Id
    @Column(name = "MEMBER_ID")
    public String getId() {
        return id;
    }

    @Column(name = "EXTERNAL_MEMBER_ID")
    public String getExternalMemberId() {
        return externalMemberId;
    }

    public String getAbc(){
        return "abc";
    }
}

I am getting exception when i start my jboss server while initializing

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: DataDB] Unable to build EntityManagerFactory
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
Caused by: java.lang.reflect.InvocationTargetException
Caused by: org.hibernate.PropertyNotFoundException: Could not find a setter for property **abc** in class com.myapp.model.Member"}}

Why it is not allowing me to have helper/convenient method inside the entity class? Why it is expecting to map with property? I am using JBoss app server with Hibernate and JPA.

sk_rdy
  • 31
  • 5

1 Answers1

2

Hibernate interpretate your getter method getAbc() as getter for abc property that should be persisted. You can use the @Transient annotation to mark the field that it shouldn't be stored in the database. Or try to put the annotations to field insted of getter method.

jahra
  • 1,173
  • 1
  • 16
  • 41