Online doc, http://ibatis.apache.org/docs/dotnet/datamapper/ch03s05.html#id358764
On 10/12/06, Per Magne Bjornerud <[EMAIL PROTECTED]> wrote:
Hello, I have a database where several subclasses are mapped to the same table. I'll stick to the standard example here. Assume Base class: Person Subclass: Employee Subclass: Customer In my application, I mostly use instances of Employee or Customer objects. But in the DB, they are both stored to the Person table. In addition to the object properties, they have a PersonType id to know which is which. Is there any way to set up iBatis mapping so the objects I get returned will be instances of the different subclasses, depending on the PersonType field? I want to do a very simple "SELECT * FROM Person WHERE Id = X" and map it to an object. Obviously identical <select> elements for each subclass and an additional lookup to know the type of each object before I select them isn't really an option. Is there a way for iBatis to handle this? I guess the alternative might be to create instances of Person objects and add a GetCorrectInstance() method that will return objects of correct subclass. If iBatis cannot help me do what I want, I'd also be happy for some tips, patterns or keywords to help me find the best possible workaround. -- Per Magne Bjornerud
-- Cheers, Gilles <a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>

