Hello,
I am currently switching from OJB to Hibernate due to restrictions that OJB has on working with Lists (OJB does not have out-of-the-box feature of storing the position number of a child)...
I think we all agree that working with interfaces instead of concrete implementations on the business layer is state-of-the-art, right ?
So, in order to persist an object I have a PersistenceManager that is doing most of the work and using Hibernate internally. This was very useful during the transistion phase from OJB, because I only had to modify very few classes. So, for example to obtain all objects of a particalur interface the PersistanceManager is called via code like this:
Code:
persistenceMgr.findAllInstances(Class interfaceClass);
So, I really would like to have a mapping file that looks like this:
Code:
<class name="Interface" type="Iterface">
....
<discriminator column="CLASSNAME" type="string"/>
<subclass name="Impl"/>
</class>
Now, usually there's only one concrete implementation of an Interface, but in order to work I'd need to have a column called "CLASSNAME" in every table and the data of this column is redundant (if we only have one impl.).
Is there anyway to have an implicit mechanism for something like this?
Furthermore, all implenations are inheritated from a basic object (BO), that provides the getter method for the unique ID. There should be no
public method to set the ID, because we don't want anybody to mess with this. The ID should be set directly using reflcetion by the framework.
So, I thought I just use
Code:
<id name="id" column="ID" type="string" unsaved-value="null" access="field">
Now, I get an exception like this:
Code:
net.sf.hibernate.PropertyNotFoundException: field not found: id
which probably occurs, because the specified Interface does not contain this field (obviously). I understand that a PropertyAccessor is requried to handle such a scenario, correct? Or is there any other way?
Any help is appreciated !!!
Regards,
Matio
---------------------------------------------------------------------------
Hibernate version: 2.1.2
Mapping document: not needed (general question)
JavaCode: not needed (general question)
StackTrace: full trace not needed
DB: HSLQDB 1.7.1
Log: not needed [/code]