Re: vertical inheritance

From: Mike Kienenberger (mkienen..mail.com)
Date: Tue Apr 17 2007 - 12:37:05 EDT

  • Next message: gdilem..ibero\.it: "create swing API directly from database table"

    Vertical inheritance is not natively supported by Cayenne yet
    (although it will need to be to be JPA-compliant, so it'll happen
    sooner rather than later).

    I've made it work by creating custom templates which override
    setPersistenceState() and then being careful how I construct queries.

    http://cwiki.apache.org/CAY/is-inheritance-supported.html

    I'm sure you'd need to do additional work to get it working with ROP.

    On 4/17/07, Marcin Skladaniec <marci..sh.com.au> wrote:
    > Hi
    >
    > In our project we have tried using inheritance, this is the
    > simplification of the map we are using:
    >
    > <db-entity name="AbstractNode">
    > <db-attribute name="id" type="INTEGER" isPrimaryKey="true"
    > isMandatory="true"/>
    > <db-attribute name="isDeleted" type="BOOLEAN"/>
    > <db-attribute name="modifiedOn" type="TIMESTAMP"/>
    > <db-attribute name="name" type="VARCHAR" length="512"/>
    > <db-attribute name="nodeType" type="VARCHAR" length="128"/>
    > </db-entity>
    > <obj-entity name="AbstractNode"
    > className="ish.oncourse.server.cayenne.AbstractNode"
    > clientClassName="ish.oncourse.cayenne.AbstractNode" lock-
    > type="optimistic" dbEntityName="AbstractNode"
    > superClassName="ish.oncourse.server.cayenne.glue.CayenneDataObject"
    > clientSuperClassName="ish.oncourse.cayenne.glue.PersistentObject">
    > <qualifier><![CDATA[(isDeleted = null) or (isDeleted = 0)]]></
    > qualifier>
    > <obj-attribute name="isDeleted" type="java.lang.Boolean" db-
    > attribute-path="isDeleted"/>
    > <obj-attribute name="modifiedOn" type="java.util.Date" db-attribute-
    > path="modifiedOn"/>
    > <obj-attribute name="name" type="java.lang.String" db-attribute-
    > path="name"/>
    > <obj-attribute name="nodeType" type="java.lang.String" db-attribute-
    > path="nodeType"/>
    > </obj-entity>
    > <obj-entity name="DefaultNode" superEntityName="AbstractNode"
    > className="ish.oncourse.server.cayenne. DefaultNode"
    > clientClassName="ish.oncourse.cayenne. DefaultNode" lock-
    > type="optimistic">
    > <qualifier><![CDATA[nodeType = "D"]]></qualifier>
    > </obj-entity>
    >
    > committing new objects works ok, but fetching the objects does not
    > work (the presence of qualifier in DefaultNode does not matter):
    > getContext().performQuery(new SelectQuery(Term.class)) throws
    > exception on server which does not tell much:
    >
    > 17/04/2007 19:05:31 com.caucho.hessian.server.HessianSkeleton invoke
    > WARNING: org.apache.cayenne.CayenneRuntimeException: [v.$
    > {project.version} ${project.build.date} ${project.build.time}]
    > Exception processing message org.apache.cayenne.remote.QueryMessage
    > org.apache.cayenne.CayenneRuntimeException: [v.${project.version} $
    > {project.build.date} ${project.build.time}] Exception processing
    > message org.apache.cayenne.remote.QueryMessage
    > at
    > org.apache.cayenne.remote.service.BaseRemoteService.processMessage
    > (BaseRemoteService.java:169)
    > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    > at sun.reflect.NativeMethodAccessorImpl.invoke
    > (NativeMethodAccessorImpl.java:39)
    > at sun.reflect.DelegatingMethodAccessorImpl.invoke
    > (DelegatingMethodAccessorImpl.java:25)
    > at java.lang.reflect.Method.invoke(Method.java:585)
    > at com.caucho.hessian.server.HessianSkeleton.invoke
    > (HessianSkeleton.java:157)
    > at com.caucho.hessian.server.HessianServlet.service
    > (HessianServlet.java:365)
    > at ish.oncourse.server.CayenneServlet.service
    > (CayenneServlet.java:102)
    > at org.mortbay.jetty.servlet.ServletHolder.handle
    > (ServletHolder.java:428)
    > at org.mortbay.jetty.servlet.ServletHandler.dispatch
    > (ServletHandler.java:677)
    > at org.mortbay.jetty.servlet.ServletHandler.handle
    > (ServletHandler.java:568)
    > at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
    > at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
    > at org.mortbay.http.HttpServer.service(HttpServer.java:909)
    > at org.mortbay.http.HttpConnection.service
    > (HttpConnection.java:820)
    > at org.mortbay.http.HttpConnection.handleNext
    > (HttpConnection.java:986)
    > at org.mortbay.http.HttpConnection.handle
    > (HttpConnection.java:837)
    > at org.mortbay.http.SocketListener.handleConnection
    > (SocketListener.java:245)
    > at org.mortbay.util.ThreadedServer.handle
    > (ThreadedServer.java:357)
    > at org.mortbay.util.ThreadPool$PoolThread.run
    > (ThreadPool.java:534)
    >
    >
    > Is the inheritance functionality is supposed to work with remote
    > persistence ? Maybe there is an error in our code ?
    >
    > Marcin



    This archive was generated by hypermail 2.0.0 : Tue Apr 17 2007 - 12:38:56 EDT