Lift 映射器中的外键约束
我在 Scala 中使用 Mapper 创建了一个表。
class Stage extends Mapper[Stage]
{
def getSingleton = Stage
object controlId extends MappedLongForeignKey (this,Control) {
override def dbNotNull_? = true
override def dbColumnName = "control_id"
}
}
但我的表没有为数据库中的外键创建约束。
I created a table using Mapper in Scala.
class Stage extends Mapper[Stage]
{
def getSingleton = Stage
object controlId extends MappedLongForeignKey (this,Control) {
override def dbNotNull_? = true
override def dbColumnName = "control_id"
}
}
but my table does not create a constraint for the foreignKey key in database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Lift 与 Rails 一样,默认情况下不会创建外键约束。如果您想启用它们,可以通过 MapperRules 来实现。在执行其他数据库初始化操作之前,将其放入
Boot
中的某个位置。var
createForeignKeys_?
是一个ConnectionIdentifier => 类型的函数。布尔值
。我想这允许您控制每个连接的外键创建,但大多数应用程序只有一个数据库连接。Lift, like Rails, does not create foreign key constraints by default. If you want to enable them, you can do so via
MapperRules
. Put this in yourBoot
somewhere before you do other database initialization stuff.The var
createForeignKeys_?
is a function of typeConnectionIdentifier => Boolean
. I suppose this allows you to control foreign key creation per-connection, but most applications only have a single database connection.