没有主键的休眠 [英] Hibernate without Primary Key
本文介绍了没有主键的休眠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Hibernate制作示例应用程序。我的要求是桌子上没有主键。我只需要从应用程序中选择查询。我知道应该有一个主键,但我所指的表没有它。
它有大约5万条记录。所以,修改表格以添加ID列并没有看到可行的选项。
它可能吗?
解决方案
- Hibernate 要求实体表具有主键故事结束
- 50k记录根本不是那么多谈论数据库。
我的建议:在表中添加一个自动增量整数PK列。你会对它的速度感到惊讶。
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 should be a primary key, but the table I am referring has been made without it.
It has about 50k records. So, modifying the table to add ID column does not see viable option.
Can it possible?
解决方案
- Hibernate requires that entity tables have primary keys. End of story.
- 50k records is simply not that many when you're talking about a database.
My advice: add an autoincrement integer PK column to the table. You'll be surprised at how fast it is.
这篇关于没有主键的休眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文