Hello everyone,
 
I'm starting to learn how to use Castor, and for this task I have set up a simple project. I want to work with a tree-like structure in a database. I have a simple class tree:
 
class Thing;
class Block extends Thing;
class Bag extends Thing;
 
wherein the Bag class has a member called "stuff", which is a collection of other Thing's. (see the attachment for full code; everything is quite straight-forward)
 
Now when I create a Bag and fill it with some Thing objects, the whole structure is successfully saved in the database, and can also be reloaded. However when I add Bag or Block objects to the Bag, they will come out of the database as Thing objects...
 
I think that's quite logical, as Castor doesn't save in the database what type an object is. Is there a way to have Castor do this automatically? i.e. without having to implement some getClassName() function or so for all classes?
 
I hope my problem is a bit clear....
 
Kind regards & happy coding,
Jan Ypma

Attachment: castor_test.zip
Description: Zip compressed data

Reply via email to