0
votes

when i insert in a table that has composite key of two fields , it fail and say it is null insertion , once i delete the composite key it insert successfully.

An exception occurred while executing 'INSERT INTO course_to_category (courseId, categoryId, ordering) VALUES (?, ?, ?)' with params [null, null, 1]:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'courseId' cannot be null

1

1 Answers

0
votes

Seems like your composite key is primary key. Check this:

A PRIMARY KEY is a unique index where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently). A table can have only one PRIMARY KEY. The name of a PRIMARY KEY is always PRIMARY, which thus cannot be used as the name for any other kind of index.

http://dev.mysql.com/doc/refman/5.1/en/create-table.html