0

My table does not have a primary key. So when I try to delete a record

Table t = Table.findFirst("col = ?", var);
t.delete();

I get below exception. Any directions?

org.javalite.activejdbc.DBException: java.sql.SQLSyntaxErrorException: ... "ID": invalid identifier

Bala
  • 11,068
  • 19
  • 67
  • 120

1 Answers1

1

ActiveJDBC does require an PK to operate. In case like yours, you need to override the delete() method, form a query that identifies your record, and call Base.exec() or DB.exec() methods internally. For clues on implementing, see the original Model#delete() method. Do the same, but only generate a different query.

ipolevoy
  • 5,432
  • 2
  • 31
  • 46