Hello,

I've tried to reproduce this locally:

create table datasets (
  id int not null primary key auto_increment,
  name varchar(250),
  user_email varchar(120),
  created_at datetime default current_timestamp
);

-- works

insert into datasets(name, user_email) values('a', 'b');


and then

DatasetsRecord rec = create().newRecord(Tables.DATASETS);
rec.setName("x");
rec.setUserEmail("y");

// works too

rec.store();


which works just fine:

12:37:54,987 DEBUG [org.jooq.tools.LoggerListener                     ] -
Executing query          : insert into `test`.`datasets` (`name`,
`user_email`) values (?, ?)
12:37:54,989 DEBUG [org.jooq.tools.LoggerListener                     ] -
-> with bind values      : insert into `test`.`datasets` (`name`,
`user_email`) values ('x', 'y')
12:37:55,356 DEBUG [org.jooq.tools.LoggerListener                     ] -
Affected row(s)          : 1
12:37:55,357 DEBUG [org.jooq.tools.StopWatch                          ] -
Query executed           : Total: 1.175s
12:37:56,009 DEBUG [org.jooq.tools.StopWatch                          ] -
Finishing                : Total: 1.828s, +652.807ms


Are you sure you have everything set up correctly in your database?

Cheers,
Lukas

2015-06-04 12:09 GMT+02:00 Alexandros G. <[email protected]>:

> Hi!
>
> I am a quite new jOOQ user and I would appreciate a little help.
> I have 2 mysql tables ("logs" and "datasets") that both use as a primary
> key a field named "id" with AUTO_INCREMENT as default value.
>
>
> <https://lh3.googleusercontent.com/-zWEAnwqRUEU/VXAjbOrYkiI/AAAAAAAAABA/yz9QOz6wlA0/s1600/logs.png>
>
>
> <https://lh3.googleusercontent.com/-IRFb-r5s9rs/VXAjdywPm4I/AAAAAAAAABI/M57y61-e1_Q/s1600/datasets.png>
>
>
> I generate all the required files for jOOQ and then try to store records
> in these 2 tables.
>
> Storing a record to the first table works fine:
>
> DSLContext database = DSL.using(this.conn, SQLDialect.MYSQL);
> LogsRecord logItem = database.newRecord(Tables.LOGS);
> logItem.setUserEmail(user_email);
> logItem.setAction(action);
> logItem.setMessage(message);
> logItem.store();
>
> Storing to the second table:
>
> DSLContext database = DSL.using(this.conn, SQLDialect.MYSQL);
> DatasetsRecord record = database.newRecord(Tables.DATASETS);
> record.setUserEmail(user_email);
> record.setName(datasetName);
> record.store();
>
> raises an Exception with the following messsage:
>
> SQL [insert into `metacatalogue`.`datasets` (`name`, `user_email`) values
> (?, ?)]; Field 'id' doesn't have a default value
>
> I am really confused! What is going wrong here?
>
> Alexandros
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to