hi,
ok maybe i am still not clear enough regarding my request.
all of the above is/was meant as an example.
the only real need is this:
i have a parent class that has an accessor which returns
a child class. during runtime the returned instances of
the child class will be of subclasses of this childclass but
never of the base child class.
once again an even more simplified example:
Code:
public class Job{
..
public Employee getEmployee(){return emp_;}
public void setEmployee(Employee _emp){emp_ = _emp;}}
class Employee{ .. }
class Programmer extends Employee{ .. }
class SalesPerson extends Employee{ .. }
the following rules do apply
1) the semantics of get/setEmployee must not change
2) the semantics of job to employee is a "to one" - which
does not necessarily imply that the hibernate mapping
must be that way. i quite open to suggestions.
3) cascading inserts/updates/deletes must be supported by
the mapping.
4) the class structure can be extended (not changed in their
semantics) if need to be (but i am very hesistant to do so).
5) the table structures can be extended if need to be as long
as the basic structure (3 tables, 2 for subclasses of employee)
remains.
@gavin:
i have looked into the any-mapping, but to be honest the documentation is quite shallow at the moment regarding this
mapping element. i would rather need concrete example of
the usage of any (if any is the solution).
as a side note:
the selection of the word "any" is not such a good idea imo.
i quite understand the "technical" reasoning for it and it somehow
captures the intended semantics quite well but googling for "any" is obviously useless and for looking up examples this is quite the
only way at the moment.
btw. i will have a very simmilar problem soon when using collections.
i will define something like the following (this again is only an
example).
Code:
public class Job
public set getEmployees(){return emps_;}
in the mapping i would have to do something like this
Code:
<set name="employees" lazy="true">
<key column="parent_id"/>
<one-to-many class="Employee"/>
</set>
only that during runtime there never will be any Employee instances
but instances of subclasses.
if somebody can show me the concrete mappings for my example
i gladly write a small document which ties it all together.
thanks
ciao robertj