• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inserting a record when the table has no primary key

 
Neerajplus Kumarplus
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm working with sybase database. The table I am trying to insert a record has no primary key. How could I insert a record in this table?

I believe hibernate allows native JDBC sql query. I could use that to persist a record but was wondering if anyone has a better suggestion to offer.

Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No PK == a broken data model. The best fix for this is to correct this error.

That being said, you can work round it. Map the table with a composite id using all the fields in the table. This will work most of the time (though since there is no PK constraint you can guarentee it will work all of the time).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic