I have a column annotated with @Transient in my application.
I can’t delete the annotation without breaking some services of the application.
However, for new features, I need it.
I tried some things with inheritance
(@Inheritance(strategy = InheritanceType.SINGLE_TABLE))
but didn’t achieve good results.
My final solution was to duplicate the entity mapping of the table, creating two entities for one table. I removed the attribute from the parent class and reassigned it to the child class.
@MappedSuperclass
public abstract classe A {
private String attributeA
}
@MappedSuperclass
public abstract classe B extends A {
private String attributeB
}
@Entity
@Table(name = "exemple")
public class C extends B {
private String noTransient
}
@Entity
@Table(name = "exemple")
public class D extends B {
//this class doesnt need the attribute
@Transient
private String noTransient
}
In this case, my old entity with the @Transient is now C, the olds services of the application are working as before, and new entity D is used for my new services.
I’m pretty sure that i can find a better solution, can you give me your opinion