{"action":"created","issue":{"url":"https://api.github.com/repos/javalite/activejdbc/issues/385","labels_url":"https://api.github.com/repos/javalite/activejdbc/issues/385/labels{/name}","comments_url":"https://api.github.com/repos/javalite/activejdbc/issues/385/comments","events_url":"https://api.github.com/repos/javalite/activejdbc/issues/385/events","html_url":"https://github.com/javalite/activejdbc/issues/385","id":61086836,"number":385,"title":"Cannot insert into tables without id column","user":{"login":"arjopoldervaart","id":6389842,"avatar_url":"https://avatars.githubusercontent.com/u/6389842?v=3","gravatar_id":"","url":"https://api.github.com/users/arjopoldervaart","html_url":"https://github.com/arjopoldervaart","followers_url":"https://api.github.com/users/arjopoldervaart/followers","following_url":"https://api.github.com/users/arjopoldervaart/following{/other_user}","gists_url":"https://api.github.com/users/arjopoldervaart/gists{/gist_id}","starred_url":"https://api.github.com/users/arjopoldervaart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arjopoldervaart/subscriptions","organizations_url":"https://api.github.com/users/arjopoldervaart/orgs","repos_url":"https://api.github.com/users/arjopoldervaart/repos","events_url":"https://api.github.com/users/arjopoldervaart/events{/privacy}","received_events_url":"https://api.github.com/users/arjopoldervaart/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-13T15:01:21Z","updated_at":"2015-03-17T05:58:54Z","closed_at":null,"body":"If a table has no id column (no primary key) Model.insert() calls DB.execInsert() and tries to autogenerate an id. This is incorrect since there is no id column.\r\n\r\nExample table:\r\nCREATE TABLE parents (father VARCHAR(56) not null, mother VARCHAR(56) not null);\r\n\r\nParent class:\r\n************************************************\r\npackage org.javalite.activejdbc.test_models;\r\nimport org.javalite.activejdbc.Model;\r\npublic class Parent extends Model {\r\n}\r\n************************************************\r\n\r\nUnit test:\r\n    @Test\r\n    public void shouldNotFail(){\r\n\r\n        Parent p = new Parent();\r\n        a(p).shouldBe(\"new\");\r\n\r\n        p.setString(\"father\", \"Time\");\r\n        p.setString(\"mother\", \"Earth\");\r\n        \r\n        p.saveIt();\r\n        \r\n        p = Parent.findFirst(\"father = ?\", \"Time\");\r\n        a(p).shouldNotBeNull();\r\n    }\r\n\r\nThe above unit test fails on both Oracle and DB2 but passes on MSSQL. As far as I understand Model.insert() and DB.execInsert, ActiveJdbc basically expects that there is always a id column."},"comment":{"url":"https://api.github.com/repos/javalite/activejdbc/issues/comments/82126405","html_url":"https://github.com/javalite/activejdbc/issues/385#issuecomment-82126405","issue_url":"https://api.github.com/repos/javalite/activejdbc/issues/385","id":82126405,"user":{"login":"ipolevoy","id":500941,"avatar_url":"https://avatars.githubusercontent.com/u/500941?v=3","gravatar_id":"","url":"https://api.github.com/users/ipolevoy","html_url":"https://github.com/ipolevoy","followers_url":"https://api.github.com/users/ipolevoy/followers","following_url":"https://api.github.com/users/ipolevoy/following{/other_user}","gists_url":"https://api.github.com/users/ipolevoy/gists{/gist_id}","starred_url":"https://api.github.com/users/ipolevoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipolevoy/subscriptions","organizations_url":"https://api.github.com/users/ipolevoy/orgs","repos_url":"https://api.github.com/users/ipolevoy/repos","events_url":"https://api.github.com/users/ipolevoy/events{/privacy}","received_events_url":"https://api.github.com/users/ipolevoy/received_events","type":"User","site_admin":false},"created_at":"2015-03-17T05:58:54Z","updated_at":"2015-03-17T05:58:54Z","body":"@arjopoldervaart, we can generate a warning, but when? When a database is scanned for table? \r\nThat migth not be that useful, as it prints all relationships when the app is initialized. Basically, not having an ID in the table is a known behaviour of the framework. "}}