Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Eclipselink Best Practices

This is an area where EclipseLink is quite flexible.

By default, EclipseLink is setup to treat 0 as null for primary keys (whether you are using wrapper objects or primitives) It is possible to configure to allow 0 as a valid values.

As far as foreign keys are concerned, usually a foreign key represents a relationship in the database. As a result, the java representation is usually either an Object reference or a Collection and not a primitive or wrapper that holds the real value. Since object references and collections can be represented as null in java, that is how they are represented. Usually this means the database value is null, but it can be set-up to use an alternate value such as 0.

-Tom

On 02/12/2011 10:27 AM, Scott Frazier wrote:
Hi,

     I have a question regarding best practices when using EclipseLink.  I'm
doing some work for a firm that uses EclipseLink heavily.  I've been told that
using primitive ints/longs for foreign keys and using zero as a sentinel value
for NULL is the best/correct/"golden path" way to use the product.  I had
assumed, a priori, that you'd require the use of wrapper classes so you could
represent NULL with null, etc.   What is the best practice around this?  Are
there tradeoffs between the two choices that might not be immediately obvious to
the EclipseLink newbie?

     Thanks in advance.  I apologize if this has been covered elsewhere, but I
couldn't find anything that sounded authoritative on the topic.

Regards,
S.



_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top