It's not a secret anymore!
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
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

OJB - Mapping a table w/o Primary Key

Mathieu Riendeau

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.


Mathieu Riendeau
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).



Dave Clark<br />Senior WebSphere Architect<br /><a href="" 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
I agree. Here's the link:
subject: OJB - Mapping a table w/o Primary Key
jQuery in Action, 3rd edition