Why cannot use compiled Insert statement in Slick

流过昼夜 提交于 2019-12-08 17:42:21

问题


Slick experts

I'm learning and playing with Slick, and I have question: the document says the Compiled Query only works for select, update and delete, http://slick.typesafe.com/doc/2.0.0/queries.html#compiled-queries

I'm curious why it does not support insert? Does it mean everytime I have to insert a row in the table, the statement needs to be re-compiled by Slick? Is there any way to compile an insert statement? Thanks!


回答1:


The documentation should be clearer here. For inserts you would cache the insert invoker instead.

val i = someQuery.insertInvoker
i.insert( foo )
i.insert( bar )

The query is only compiled once.

I created a pull request to improve our documentation on this point: https://github.com/slick/slick/pull/629



来源:https://stackoverflow.com/questions/21422394/why-cannot-use-compiled-insert-statement-in-slick

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!