Hi,
I'm trying to do something that seems simple, but is causing me grief...
I'm trying to set up:
* A class that is a hibernate entity, using annotations, with getters and setters (perfectly normal).
* A second class that subclasses this class, and overrides one of the getters.
Unfortunately, the problem I have is:
* If I override the getter, and put no annotations on it, hibernate tries to treat the property name as a column name, instead of using the annotation on the true getter in the superclass.
* If I add in a column annotation, Hibernate tells me 'repeated column name'.
For example:
Code:
@Entity
@Table(name = "TestBean")
@DiscriminatorColumn(name = "DiscrimCol",discriminatorType = DiscriminatorType.INTEGER)
@DiscriminatorValue("1")
public class TestSuperBean
{
private long cSeq;
private String cID;
public TestSuperBean()
{
}
@Id @GeneratedValue
@Column(name = "TestBeanSeq")
public long getSeq()
{
return(cSeq);
}
public void setSeq(long seq)
{
cSeq = seq;
}
@Column(name = "TestBeanID")
public String getID()
{
return(cID);
}
public void setID(String id)
{
cID = id;
}
}
@Entity
@DiscriminatorValue("2")
public class TestSubBean extends TestSuperBean
{
@Column(name = "TestBeanID")
public String getID()
{
return(super.getID());
}
}
In the above, if I leave off the @Column (in the subclass), I get an error attempting to write to a column named 'ID'. If I put the annotation ON, I get the 'repeated column' error.
I know I could take the annotation out of the superclass, and only put it in the subclass, but it seems silly that I would have to jump through hoops -- I really want hibernate to recognize that this is overridden, and behave appropriately.
I can't seem to find any references to this kind of thing anywhere -- is this even possible?
TIA for any help!