2016-04-28 41 views
0

如何使用複合標識符爲實體寫入squeryl中的deleteWhere子句?複合鍵和在squeryl中的位置

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) 
             ^

回答

2

隨着CompositeKey,所述id方法不直接映射到一列,所以它不是在in子句是有用的。您必須構建您的引用每個構成私鑰的列的位置。不知道涉及的列很難更具體,但像

deleteWhere(q => existing.map(e => q.id1 === e.id1 and q.id2 === e.id2).reduce(_ or _))