0

I have two classes A & B, B extends A and A is @MappedSuperclass as it is extended by other entities as well for some common fields.

Class A

@MappedSuperclass
public class A implements Serializable { 

@Column(name="TYPE_ID")
private String type;

@Column(name="FEATURE_CODE")
private String featureCode;

}

Class B

public class B extends A implements Serializable { 

@Column(name="ID")
private String id;

@Column(name="GROUP")
private String group;

}

Now the problem is while I'm trying to persist class B it takes TYPE_ID and FEATURE_CODE into the INSERT query and the target database table TABLE B doesn't have the column FEATURE_CODE which results in exception.

Can anyone point me in the right direction on how to ignore the FEATURE_CODE field while persisting the child entity B? Thanks !

ngCoder
  • 2,095
  • 1
  • 13
  • 22

1 Answers1

0

@MappedSuperclass needs a constructor and its get and set. and your class, B,..

must have the columns of A in the database, if you do it with hibernate you should create them automatically, but if you do it manually, you must create the columns of A in the table of B