Class1:
int field2
Class2 field1
Class2:
Class3 field3
Class3:
String field4
String field5
Class1 domain class:
@Table(name = "class1_details")
@Entity
public class Class1Details {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private long id;
@Column(name = "class2_fields")
private Class2 fields;
// respective getters and setters
}
I am using springboot. I am extending JPARepository for my repo interface. I want to save class1 in db. I am getting below exception:
org.springframework.orm.jpa.JpaSystemException: could not serialize; nested exception is org.hibernate.type.SerializationException: could not serialize ...
Caused by: org.hibernate.type.SerializationException: could not serialize ....
Caused by: java.io.NotSerializableException: com.model.Class3 ...
Tried @ElementCollection but of no use. Please help with this.
SerializableCaused by: org.postgresql.util.PSQLException: ERROR: null value in column "class3_id" violates not-null constraintI havent declared any class3_id in class3. Do i need to create domain classes (@entity class) for class2 and class3 as well?