persistence@glassfish.java.net

Re: Re: Does "the class must have a public no-argument constructor" mean that I must declare it, even if it is the sole constructor?

From: Markus KARG <karg_at_quipsy.de>
Date: Fri, 25 Apr 2008 16:42:05 +0200

Hello /lexi,

thank you for that explanation. I already assumed that, but I just
wanted to be sure. :-)

Thanks
Markus

Aleksei Valikov schrieb:
> Hi.
>
>
>> The EJB 3.0 Persistence specification says for entities and primary keys,
>> that those classes must "have" a public no-argument constructor.
>>
>> In the case that I do not have any other constructors, does "have" mean
>> that I must declare such a constructor (even if it is useless, since the
>> default constructor can serve the same purpose), or is the implicit default
>> constructor enough to "have"? In other words, can I omit my empty
>> constructor IN THAT CASE in favour of the default constructor?
>>
>
> In this case the default constructor is the public no-arg constructor,
> you don't need to redeclare anything.
> The idea is that the EJB layer could call yourClass.newInstance() to
> construct a new instance.
>
> Bye.
> /lexi
>


-- 
QUIPSY QUALITY GmbH & Co. KG
Ein Unternehmen der MES-Gruppe
Stuttgarter Strasse 23
D-75179 Pforzheim
Tel: 07231-9189-52
Fax: 07231-9189-59
www.quipsy.de
karg_at_quipsy.de
Registergericht Mannheim HRA 701214
Geschäftsführer: Nils Schroeder
Diese E-Mail enthält persönliche, vertrauliche und vor Weitergabe geschützte Informationen und ist ausschließlich für den vorgesehenen o.g. Empfänger (Adressaten) bestimmt. Falls Sie diese E-Mail versehentlich erhalten haben und nicht der vorgesehene Empfänger sind, bitten wir Sie, die E-Mail und deren Anhänge nicht aufzubewahren, nicht zu vervielfältigen, nicht zu nutzen und nicht weiterzugeben. Bitte informieren Sie uns als Absender über diesen Zustellungsfehler und löschen Sie die E-Mail.