Georg, We went through these type of problems several times now. And I would say that using some tools we�ve resolved them "trusting" the tools proposed solutions (we believed those tools bring us others collegues knowledge and experience to our IDEs). This approach let us focus on the business side of building an app.
We use Poseidon 2.x CE (www.gentleware.com) to model this type of problems and then we let AXgen from Peter Wieland (http://axgen.sourceforge.net/ Thanks Peter!) to generate repository user file, sql ddl and java code. This approach is very usefull when we do not need to reuse legacy RDMBS models. I�ve just did a sketch of your problem and have everythin ready to be implemented in 3 mins. Following AXgen Velocity based code generation patterns, an InventoryClass can be an Item or a Catalog, and depending future uses, you can define ItemCatalog and Item to be Abstract or Concrete classes (Axgen is expecting you to declare them as steretype Interfaces when you are not going to instantiate them). Then, a Item can be whatever you need to extends from it (Book, CompactDisc etc.). The key here is even with Catalog extending InventoryItem it HAS a collection of InventoryItems. Axgen patterns are based in a heavy use of interface programming. You can modify the code generator to your preferred patterns (Axgen uses Velocity templates). I�m mailing you the Poseidon based file with the model. Regards, Gustavo. "Georg Klima" <[EMAIL PROTECTED]> wrote on 28/04/2004 05:55:38 a.m.: > Hello! > > I'm quiet new to ojb and maybe haven't read all possible materials > about it. Excuse me if this is real newbie!! > > Problem: > > I have a library (university project) which has a COMPOSITE PATTERN > (the one from gamma et'al) for implementing the storing of > different types of objects (cds, books.... / catalogs and subcatalogs) > generic. > > --------------------- 0..* "has-a" > | InventoryEntry |<-------------- > |-------------------| | > | Operation() | | > --------------------- | > ? | > | | > | "i-as" | > -------------------- | > | | | > | | | > ---------------- ----------------------- | > | Item | | Catalog |--- > ---------------- ----------------------- > |Operation() | | Operation() | > --------------- | Add(InentoryEntry) | > |Remove(InentoryEntry)| > |---------------------| > |Collection i_entries | > ----------------------- > > Item and Catalog have a "is-a" relationship with > Inventory Entry! > Catalog has a "has-a" relationship with Inventory > Entry. > > Later in the implementation the Books and CDs should > be derived from Item (for now it's sufficient to say > a book or what ever is an instance of Item). > > So how to model this in the database and the repository > with storing instances of item and Catalog to the > same Collection (i_entries) in java. > (I do this by now having a Items Collection and a > Catalog Collection in the Catalog Class. but these > two different Collections should be merged to one in java). > > Besides this: > A Catalog can have null or many (sub)catalogs > and a Catalog can have null or many Items. > A Item can be in one or many (sub)Catalogs. > > --> so I'm not only building a simple tree structure > with this pattern, rather a more complex structure > with everything allowed than circular graphs > (because of then occurring endless loops traversing > the structure). > > Excuse my bad English, but I haven't sleeped that much > last night! > > Thanks > Georg > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
