Hibernate without Primary Key

前端 未结 5 1426
梦如初夏
梦如初夏 2020-12-03 08:00

I making a sample application with Hibernate. My requirement is that there is no primary key on the table. I had to do only select query from application. I know there shoul

5条回答
  •  暖寄归人
    2020-12-03 08:18

    So, modifying the table to add ID column does not see viable option.

    Why's that? Do you just mean, because it already has fifty thousand records? Trust me, that's really not very many.


    Even if the table doesn't have a surrogate key, and doesn't have a primary-key constraint, and even if you're not willing to alter the table, it still probably has some sort of candidate key — that is, some set of columns that are never null, and whose values uniquely identify a record. Even without altering the table to enforce their uniqueness and non-nullity, you can tell Hibernate that those columns form a composite ID.

提交回复
热议问题