I'm extending from a utility base class that maps id to columns
@MappedSuperclass
public abstract class BaseDTO
{
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public int id;
public int getId() {
return id;}
public void setId(int id) {
this.id = id;}
}
This class is used in many derived classes to provide simplified access and operations to tables that contain id columns. i.e.
BaseDTO->DBAbstractClass1->DBAbstract2->MyClassDTO
BaseDTO->DBAbstractClass1->DBAbstract3->AnotherADTO
BaseDTO->DBAbstractClass2->DBAbstract4->AnotherBDTO
etc.
Now I find I have a table mapped to MyClassDTO that does not have an 'id' column (it has a column called 'identifier') but due to architecural constraints, exending as per normal causes:
[org.hibernate.util.JDBCExceptionReporter] SQL Error: 1054, SQLState: 42S22
[org.hibernate.util.JDBCExceptionReporter] Unknown column 'this_.id' in 'field list'
I have tried overriding the id member as @Transient, adding a new @Id etc. but always get the error above.
Either I find a way of 'ignoring' or replacing the inherited id or I need to copy my inherited classes and not extend BaseDTO, which is something that a good programmer should avoid.
I have seen something simlar at Hibernate : How override an attribute from mapped super class but I's not sure it solves my exact problem.
It's probably a simple override, but want to be careful that there are no side affects. Any takers?