GeeCON Prague 2014*
The moose likes Object Relational Mapping and the fly likes OJB - Mapping a table w/o Primary Key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "OJB - Mapping a table w/o Primary Key" Watch "OJB - Mapping a table w/o Primary Key" New topic
Author

OJB - Mapping a table w/o Primary Key

Mathieu Riendeau
Greenhorn

Joined: Mar 23, 2005
Posts: 1
Hi there,

My problem is really simple.

How do I map an object to a table without primary key? Because OJB requires at least 1 primary key.

Thx

Mathieu Riendeau
mriendea@ca.ibm.com
Dave Clark
Ranch Hand

Joined: Feb 16, 2005
Posts: 52
why would you want to have a table without a primary key?? primary keys are kinda one of the underpinnings of relational database theory...

how would your persistence layer know which row to update if you fetched an object, changed it's value, and wanted the changes to be persisted? You need a unique identifier for this - i.e. a primary key on the table.

Or are you actually asking a question about JDO's facilities for application identity (ID's visible to the app), versus datastore identity (IDs managed by the JDO runtime, but still stored as primary keys in an RDBMS).

cheers,

Dave


Dave Clark<br />Senior WebSphere Architect<br /><a href="http://www.versant.com" target="_blank" rel="nofollow">Versant Open Access - JDO2 & EJB3</a>
Gobind Singh
Ranch Hand

Joined: Aug 04, 2006
Posts: 62
I also have the same question. Is it possible to use hibernate mapping to insert into a table that does not have a primary key defined??
Ghulam Rashid
Ranch Hand

Joined: Jan 14, 2002
Posts: 278
Look into this thread regarding PK.
Hibernate supports for PK
 
Don't get me started about those stupid light bulbs.
 
subject: OJB - Mapping a table w/o Primary Key