可以不使用 ID 字段而使用另一个列名吗?在电梯里
我从 scala/lift Web 应用程序连接到 Oracle 数据库。我已经能够按照我的意愿成功地从数据库中提取信息,但遇到一个问题。
对于我想要访问的每个表,我需要添加一个 ID 字段,以便应用程序能够使用特征 IdPK。
我可以使用什么映射器类或特征来覆盖它?我一直在努力寻找,但未能找到。人们并不总是在他们创建的每个表上都有一个 ID 字段,即所谓的 ID...
class DN_REC extends LongKeyedMapper[DN_REC] with IdPK {
def getSingleton = DN_REC
object dn_rec_id extends MappedInt(this){
}
这就是我所说的。我想使用 dn_rec_id 作为我的主键,因为它在表上。
谢谢
I am connected to a oracle database from a scala/lift webapp. I have been able to successfully pull information from the database as I wished but am having one issue.
For each table I want to access I am required to add an ID field so that the app will work with the trait IdPK.
What mapper class or trait can I use to override this? I have been trying to find one but been unable to locate it. Figured people have not always had an ID field on every table they make that is just called ID...
class DN_REC extends LongKeyedMapper[DN_REC] with IdPK {
def getSingleton = DN_REC
object dn_rec_id extends MappedInt(this){
}
This is what I am talking about. I would like to use the dn_rec_id as my primary key as it is on the table.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有理由必须使用 IdPK 特征。如果你检查源代码,你会看到它的定义如下:
所以基本上,它只是创建一个名为 id 的长索引并使其成为主键。您可以使用 id 的其他名称轻松地自行完成此操作。
No reason you have to use the IdPK trait. If you check source, youll see its defined as following:
So basically, it justs creates a long index named
id
and makes it the primary key. You can easily do this yourself with another name for the id.