Hallo guys I'm using Ktor + Exposed as my backend...
# server
j
Hallo guys I'm using Ktor + Exposed as my backend stack I'm no expert with these technologies but for the past weeks I got the hang of it Today I was trying to create an Insert Stamente but I keep running into a weird issue where it says that
java.lang.IllegalStateException: com.assisuni.db.student.TableStudent.id is not in record set
The weird thing is that when checking the table,it shows the new record inserted even when an error was thrown during the insert operation Has anyone faced the same issue
Copy code
override suspend fun enrolStudentIntoSubject(subjectOfBatchId: Int, idOfStudent: Int): EnrolledSubjectModel? {
        return  try {
            var statement:InsertStatement<Number>? = null
            db.dbQuery {
                statement = TableEnrolledSubjectStudent.insert {

                    it[batchSubjectId] = subjectOfBatchId // reference
                    it[studentId] = idOfStudent // reference to table student Id
                }
            }
            statement?.resultedValues?.get(0)?.let {
                exposedLogger.debug("Student $idOfStudent was Enrolled  into subject of batch $subjectOfBatchId")
                EnrolledSubjectModel.fromRow(it)
            }
        }catch (e:ExposedSQLException){
            exposedLogger.debug("Failed to enrol student $idOfStudent  to subject of batch $subjectOfBatchId")
           throw e
        }
    }
👍 2