I have met a situation that my entity may related to the tables which has different columns.
For example, my entity has 2 properties(A and B). Related tables may have two versions, one table has A column only and the other table has A and B columns.
So if using entity in one column table, it will raise exception about the property B
I try to use @Transient
to mark B properties. It does not meet exception in one column situation. But in two columns table, the column B's information is missing since I omit B properties.
So, I expected when in one column table, the B properties can be set as null. Also in the two columns table, the B properties value can be caught from DB.
I try to use the @MappedSuperclass
to create a base abstract class and create a class extends base class. But no matter where I put B properties, in base class or extended class. Or no matter which I use findAll() method or use @Query(native sql query) to query, it still raise the same exception as before.
When using findAll(): ERROR: column table.B does not exist
When using @Query(native sql query): The column name B was not found in this ResultSet.