Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Question regarding setting default values with @Embedded

I don't have any specific experience doing this, but the Constructor
seems like a sane place to do this, since there's no way to create the
object without calling it's default constructor.

./tch



On Tue, Aug 3, 2010 at 6:23 PM, Kevin Haskett <KHaskett@xxxxxxxxxxx> wrote:
> What would be the best way to set default values with @Embedded fields
> within a Domain object -
> @Entity
> @Table(name = "CP_TRANSACTION")
> @Cache(alwaysRefresh = true)
> @Converter(name = "boolean", converterClass =
> com.gmrc.jpa.domain.mappings.converters.BooleanYNConverter.class)
> public class CpTransaction extends BaseDomain {
>     @Embedded
>     private CpActionCode cpActionCode;
> ....
>
> @Embeddable
> public class CpActionCode implements java.io.Serializable {
>     public static final String ADD = "A";
>
>     public static final String DELETE = "D";
> ...
>     @Column(name = "ACTION_CODE", length = 1)
>     private String actionCode = CpActionCode.ADD;
>
>     /** default constructor */
>     public CpActionCode() {
>     }
>
> I would like it to default to the ADD code when a new entity is created.  Is
> it as simple as setting it in the constructor?
>
> Thanks,
> Kevin
>
> This message (including any attachments) is intended only for the use of the
> individual or entity to which it is addressed and may contain information
> that is non-public, proprietary, privileged, confidential, and exempt from
> disclosure under applicable law or may constitute as attorney work product.
> If you are not the intended recipient, you are hereby notified that any use,
> dissemination, distribution, or copying of this communication is strictly
> prohibited. If you have received this communication in error, notify us
> immediately by telephone and (i) destroy this message if a facsimile or (ii)
> delete this message immediately if this is an electronic communication.
> Thank you.
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>
>


Back to the top