npmrtsv
npmrtsv

Reputation: 434

Composite key and where in in squeryl

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

Upvotes: 0

Views: 240

Answers (1)

Dave Whittaker
Dave Whittaker

Reputation: 3102

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

Upvotes: 2

Related Questions