Re: Empty Constructor

From: Mike Kienenberger (mkienen..laska.net)
Date: Thu Jun 30 2005 - 15:25:42 EDT

  • Next message: Kevin Menard: "Re: Subclassing a DataObject"

    Kevin Menard <kmenar..ervprise.com> wrote:
    > If you haven't guessed by now, I'm trying to integrate Cayenne into a
    > new project here, thus all the questions ;-)
    >
    > I have a DataObject with some fields that I would like to be not
    > null. Typically, for such things, I'd force them to be passed into
    > the constructor to strengthen this commitment. So, I naively set
    > about doing that with my DataObject. Alas, it appears an accessible
    > empty constructor is necessary for retrieving things from the DB. Is
    > this in fact the case? I'd rather not have people instantiating the
    > no-arg constructor . . .

    Yes, Cayenne needs a no-arg constructor. Something generic has to be out
    there for the VM to build a new object when a set of DataObjects is
    constructed.

    However, you might be able to make it a private constructor since Cayenne
    uses Constructor.newInstance() to create it.

    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/Constructor.html#newInstance(java.lang.Object[])



    This archive was generated by hypermail 2.0.0 : Thu Jun 30 2005 - 15:22:50 EDT