I think Hibernate must know the exact object type when you start the session.
So, perhaps the best way to implement that you want is to create a custom hibernate type.
Another easy solution I propose you is to store all as a String, so hibernate know the exact object type. Then you can add several getters and setters for integers and String, something like:
Code:
public class Sample<T>{
private String Id;
public Sample(){
}
public Sample(T id){
Id = id.toString();
}
public void setId(T id){
Id = id.toString();
}
public T getId(){
return Id;
}
}
I havnt compiled the code, is only a suggestion.
hope this help