Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Does EclipseLink support Primary Key-Less Entities?

In short yes.  Note that the Entities Id does not have to have a primary key
constraint on the database, or be the primary key of the table (although it
almost always is, and should be).  Any set of unique fields will do.

If you truly have no set of unique fields, then using them all should be
fine.  Even if two objects had all the same fields, they would effectively
be the same object anyway, as they would have all of the same data.

See also:
http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#No_Primary_Key


Tim Hollosy wrote:
> 
> I know the JPA spec requires a Primary Key for an entity.
> 
> What's the recommended way to get around this with views without a
> primary key? Just do a large compound primary key that's pretty safe
> to be unique?
> 
> 
> Thanks,
> Tim
> 


-----
---
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.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/Does-EclipseLink-support-Primary-Key-Less-Entities--tp17186718p17187205.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top