组合键和 squeryl 中的位置
Composite key and where in in squeryl
如何在 squeryl 中为具有复合 ID 的实体编写 deleteWhere 子句?
val list: List[CompositeKey2[Long, Date]] = existing.map(x => x.id).toList
Schema.entities.deleteWhere(q => q.id in list)
Error:(82, 49) value in is not a member of org.squeryl.dsl.CompositeKey2[Long,java.util.Date]
Schema.entities.deleteWhere(q => q.id in list)
^
对于 CompositeKey,id
方法不会直接映射到列,因此它在 in
子句中没有用处。您必须在何处构建单独引用构成私钥的每一列的结构。在不知道所涉及的列的情况下很难更具体,但是像
deleteWhere(q => existing.map(e => q.id1 === e.id1 and q.id2 === e.id2).reduce(_ or _))
如何在 squeryl 中为具有复合 ID 的实体编写 deleteWhere 子句?
val list: List[CompositeKey2[Long, Date]] = existing.map(x => x.id).toList
Schema.entities.deleteWhere(q => q.id in list)
Error:(82, 49) value in is not a member of org.squeryl.dsl.CompositeKey2[Long,java.util.Date]
Schema.entities.deleteWhere(q => q.id in list)
^
对于 CompositeKey,id
方法不会直接映射到列,因此它在 in
子句中没有用处。您必须在何处构建单独引用构成私钥的每一列的结构。在不知道所涉及的列的情况下很难更具体,但是像
deleteWhere(q => existing.map(e => q.id1 === e.id1 and q.id2 === e.id2).reduce(_ or _))