Making subclasses have transient fields

Hello,
I haven’t found a solution for this issue so much because I might have more to do with jpa doing this logic at compile time, but I essentially need a way to have hibernate ignore an annotation in a subclass, that way we don’t have this extra column in the database. I know we should probably introduce an interface so we don’t have to worry about the column, however since I have a large code base, it isn’t the easiest thing to do. Is there a way I could let hibernate ignore a column in a subclass, so when I pull in the items it doesn’t look for the column?

@MappedSuperclass
public class Person {
	String address;
	
	@Column( name = "address_column")
	public String getAddress() {
		return address;
	}
	
	private void setAddress(String address) {
		this.address= address;
	}
	
}

@Table(name = "web_user")
public class WebUser extends Person {

	@Override
	@Transient
	public String getAddress() {
		return address;
	}

}

This is not possible. You have to understand that a persistent attribute that is declared on a type can’t suddenly disappear in a subtype. You should definitely push attribute definitions down to the concrete entity definitions and avoid the use of mapped superclasses for such use cases.

Hello,

I understand the idea of ​​imposing to take everything to respect the modeling, but isn’t it a bit strict?
Let me explain, we want to migrate a big and old project (efluid - 2000) to hibernate and the modeling is not always so perfect.

And it is extremely complicated to intervene on central and very widespread objects.

There is no way around this?

I don’t know what you mean. If you have a new question, then please create a new topic.

I do that :slight_smile: thank you in advance