safarje wrote:
Hi,
Right now , Hibernate instantiates a class based on its real name and does a simple newInstance on the class it obtained.
I was wondering whether some slightly more sophisticated factory mechanism had been contemplated.
I would like to not put the name of the real class but rather put a logical name for it from which a factory could be obtained and an instnace created using a newInstance call on it.
I could not find it anywhere, can it be done today?
thank's
Jean Safar
To confirm I understand you.
You wish Hibernate to instate concrete classes through a factory class ?
My understanding of Hibernate is that it is an Object Relational Mapping system that is based on clear reversable rules between concrete classes and JDBC data access (through mapping information). Since its purpose is to be able to persist concrete classes.
Hibernate only instates classes that were fetched from persistant storage. For them to be in persistant storage in the first place they must have been a concrete representation of some object in the past.
So I don't understand your design pattern that introduces a factory class in the middle. You can only ask Hibernate to fetch a concrete class, if you need a factory to work out exactly which concrete class you want, this sounds more like work that should be done in your DAO layer, that sits above Hibernate.