> -----Original Message----- > From: Rick Curtis [mailto:[email protected]] > Sent: Friday, December 04, 2009 12:31 PM > To: [email protected] > Subject: Re: Why does the enhancer create a PROTECTE no-args > constructor by default? > > David- > > Per the JPA spec -- > > The entity class must have a no-arg constructor. The entity class may > have > other constructors as well. > The no-arg constructor must be public or protected. > > ...so if your Entity doesn't have one, OpenJPA will do it for you.
Ok, I'll phrase the question again, and perhaps I can make it more obvious this time. Why does the enhancer create a PROTECTED no-args constructor, and not a PUBLIC one? If it was going to create a PUBLIC constructor, there'd be absolutely no point to this, because that's exactly what the JVM does. If the enhancer had a good reason to create a PROTECTED constructor instead of a PUBLIC one, then I can see why the enhancer would do this, but I still see no obvious reason to create a PROTECTED constructor. Is that clearer now? > -- > Thanks, > Rick > > On Fri, Dec 4, 2009 at 1:29 PM, KARR, DAVID (ATTCINW) > <[email protected]>wrote: > > > I'm reading the OpenJPA doc, and I see that the enhancer creates a > > protected no-args constructor if there is no public one. Why exactly > > does it do that? What is the point of creating a protected > constructor > > instead of letting the JVM create the public one? The doc only says > > that it does this, not why. > >
