Re: Conditional relationship mapping?

From: Joseph Schmidt (joseph_schmidt7..ahoo.com)
Date: Thu Apr 02 2009 - 06:51:28 EDT

  • Next message: Dave Lamy: "Quick query question"

    > > This would sound cool to me too, but from the Cayenne
    > documentation example, this approach seems to have the
    > problem that Java has single inheritance :(.
    > >
    > > If there's only one such table than it would work
    > (single inheritance).
    > > E.g. In the above example, by doing a superclass to
    > point to the "tag" table(Tag entity), called "Taggable". All
    > entities that would like to have "tag"s would just need to
    > extend the "Taggable" entity.
    > >
    > > The big problem is how to do it if there are more
    > tables like that in the scheme :(.
    >
    > Yes, you get to have exactly one Tag concept since you can
    > have only one superclass. Otherwise you have to model this
    > as an interface, but there is no support for that in
    > Cayenne.
    This would have been my first choice too, but I saw no support in Cayenne Modeler for entering additional interfaces - only one super class :(.

    > >> Choice 2:
    > >> Just do exactly what you are doing and fake the
    > >> relationships. Subclass CayenneContext so that you
    > can
    > >> create the appropriate setters and getters to make
    > this all
    > >> work. We do this ourselves and I might be able to
    > dig up
    > >> some code if you get stuck.
    > > Are there any examples about this around?
    >
    > You could download the onCourse server from our website
    > (www.ish.com.au/oncourse) and open it up.
    This looks like a very nice application :).

    (I haven't seen too many cayenne based applications since
    some of the links from http://cayenne.apache.org/success-stories.html
    don't work or they don't point to a download-able application :( )

    > Inside there you'll
    > find our Cayenne model for the application (use version 3
    > modeler to look at it). And in there, some tables called
    > Node and NodeRelation are of interest to you. In the
    > application itself, we use this to display 'Tags' attached
    > to lots of different entities: courses, students, etc.
    >
    > Here's a snippet of code which then let's you find the
    > related records. In this Taggable is the interface, Node the
    > "Tag" entity and NodeRelation the join to other entities.
    Interesting idea.

    Thank you very much for the detailed example.
    I'll try to model like you describe.

    Joseph.

          



    This archive was generated by hypermail 2.0.0 : Thu Apr 02 2009 - 06:53:04 EDT