1
は、私は私のデシベルに製品を挿入しようとしないんだけど、実際には、私は私のモデルがどのように見えるん何もスリックは挿入しませんが、エラー
挿入:テーブル定義
case class Product(id: Option[Int], name: String, description: String, style: String, price: Int, cat_id: Int, size_id: Int, brand_id: Int)
:
DAOでclass ProductsTable(tag: Tag) extends Table[Product](tag, "PRODUCTS") {
def id = column[Int]("PRODUCT_ID", O.PrimaryKey, O.AutoInc)
def title = column[String]("NAME")
def description = column[String]("DESCRIPTION")
def style = column[String]("STYLE")
def price = column[Int]("PRICE")
def category_id = column[Int]("CATEGORY_ID")
def size_id = column[Int]("SIZE_ID")
def brand_id = column[Int]("BRAND_ID")
def category = foreignKey("CAT_FK", category_id, cat.Categories)(_.cat_id, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.Cascade)
def size = foreignKey("SIZE_FK", size_id, sizes.Sizes)(_.size_id, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.Cascade)
def brand = foreignKey("BRAND_FK", brand_id, brands.Brands)(_.brand_id, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.Cascade)
def * = (id.?, title, description, style, price, category_id, size_id, brand_id) <>(Product.tupled, Product.unapply _)
}
Insertメソッド:
def insert(product: Product): Future[Unit] = db.run(Products += product).map { _ =>() }
およびコントローラ:
def newproduct = Action { implicit request =>
val product: models.Product = productForm.bindFromRequest().get
productDAO.insert(product)
Redirect(routes.ProductController.listproducts())
}