Re: Self-Join query

From: Cris Daniluk (cris.danilu..mail.com)
Date: Wed May 25 2005 - 10:41:01 EDT

  • Next message: Cris Daniluk: "Re: JNDI problem..."

    Actually, the best way to do this is probably through a relationship.

    Create a toParent relationship on the CdMenu DBEntity that links
    child_id to parent_id. Then, something like

    cdMenu.getToParent().getName() will get you the name of the parent. If
    you absolutely have to have both in the same object, then Joe's
    SQLTemplate request is the best way to go.

    On 5/25/05, McDaniel, Joe R. <mcdanij..igr.org> wrote:
    > You can certainly do this with as SQLTemplate query as in:
    >
    > SQLTemplate sqlTemplateQuery = new SQLTemplate(CdMenu.class,
    > "select child.name,parent.name from cd_menu as child inner
    > join cd_menu as parent on child.parent_id=parent.id"),
    > true);
    >
    > You get back a Map instead of CdMenu objects.
    >
    > Joe
    >



    This archive was generated by hypermail 2.0.0 : Wed May 25 2005 - 10:41:04 EDT