0

How can I write deleteWhere clause in squeryl for entity with composite id?

    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)
                                          ^
npmrtsv
  • 434
  • 6
  • 22

1 Answers1

2

With a CompositeKey, the id method doesn't map directly to a column, so it isn't useful in an in clause. You'll have to structure your where to reference each column that makes up the private key individually. Without knowing the columns involved it's tough to be more specific, but something like

deleteWhere(q => existing.map(e => q.id1 === e.id1 and q.id2 === e.id2).reduce(_ or _))
Dave Whittaker
  • 3,102
  • 13
  • 14