Skip to main content

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

>> 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 would not say that.  In general if your database allows null for a column,
then it is best to use the primitive wrapper, so you can represent null
correctly.  Substituting 0 will work, but if both 0 and null were valid
values in your application with different meaning, then a primitive would
not work.

EclipseLink fully supports using primitives and for ids will assume by
default that 0 means null (but can be configure otherwise), but representing
null correctly as null is in general better.


Scott Frazier-2 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.
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.eclipse.org/forums/index.php?t=thread&frm_id=111&S=1b00bfd151289b297688823a00683aca
EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/Eclipselink-Best-Practices-tp32902992p32929917.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top