Can anyone tell me how I might get my hands on the id (primary key) setter method of a hibernate persistent class at runtime?
Say I have a hibernate class :
Code:
public class A {
Integer id;
public void setId(Integer id) {
this.id = id;
}
<other getters/setters etc.>
}
At runtime I have an instance of A, cast as an object. I want to be able to get a reference to the id setter method.
Code:
Object o = <instance of some persistent class>;
Method pkSetter = <the primary key setter setId()>;
pkSetter.invoke(o, { args }); // etc.
I assume this is possible through hibernate, since this information is specified in the hbm file for each class.
I have looked into SessionFactory.getClassMetadata(), but can't seem to find any references to the primary key setter/getter methods.
Thanks in advance,
Keith