如何在具有复合ID的实体的squeryl中编写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)
^
答案 0 :(得分:2)
使用CompositeKey,id
方法不会直接映射到列,因此它在in
子句中没用。您必须构建自己的位置,以便单独引用构成私钥的每个列。如果不知道所涉及的列,就很难更具体,但是像
deleteWhere(q => existing.map(e => q.id1 === e.id1 and q.id2 === e.id2).reduce(_ or _))