Skip to main content

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

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.


Back to the top