tags:

views:

1578

answers:

2

Anyone knows how to do hibernate mapping for table or view without a primary key?

thanks.

+2  A: 

Don't think Hibernate allows mapping a table without a primary key...think about how Hibernate would perform updates without a column that can uniquely identify a row.

I guess a work-around would be to use a composite key with all columns, but you are much better off adding a primary key.

Ryan Anderson
I think you are correct here. Also the composite key (of all columns) would still need to be primary, so your better off making a more reasonable composite key or choosing a uniquely identifying column as the primary key.
James McMahon
+1  A: 

see http://stackoverflow.com/questions/767277/hibernate-and-no-pk

Schildmeijer
Good find, question should be closed as a duplicate.
James McMahon