Hi Lukas,


> DSL.val() and DSL.value() are synonyms. The latter has been introduced for
> better Scala interoperability, precisely for this reason.
>
Ahhh, ok, I missed that one :-) Thanks!

2) I'm not sure if this is really a jooq issue or if this is an issue at
>> all :-) I'm using postgresql's serials for my id columns which implicitely
>> creates an integer column and a sequence. Consequently, jooq generates an
>> ID field of type Integer and a sequence of type Long which seems to be
>> correct.
>>
>
> That sounds like a bug to me. Could you provide us with the table's DDL?
>
For example you can just do (I'm using PostgreSQL 9.3):

create table sequence_test (
id serial primary key
);

That generates a table with an id column of type serial which is a 4-byte
signed integer that only uses positive numbers. On the other hand, postgres
implicitely generates a sequence called sequence_test_id_seq. Sequences in
postgres have a default max value of (2^63)-1, i.e. an 8 byte integer. So
there is already a "problem" (it is not really a problem because it is
intended behaviour) in postgres because default sequences can generate
values that do not fit into serial columns. That's why I said jooq seems to
generate the correct table definitions. Let's have a look at them (I'm
using jooq 3.2.2). First, the Sequences class:
public class Sequences {
/**
 * The sequence <code>public.sequence_test_id_seq</code>
  */
public static final org.jooq.Sequence<java.lang.Long> SEQUENCE_TEST_ID_SEQ
= new org.jooq.impl.SequenceImpl<java.lang.Long>("sequence_test_id_seq",
models.Public.PUBLIC, org.jooq.impl.SQLDataType.BIGINT.nullable(false));
}

We have a field of type long which, again, seems to be correct because
longs have a max value of (2^63)-1 which perfectly fits postgres' sequences.
Next, the table definition (I only show the ID field):
public class SequenceTest extends
org.jooq.impl.TableImpl<models.tables.records.SequenceTestRecord> {
...
/**
  * The column <code>public.sequence_test.id</code>.
 */
 public final org.jooq.TableField<models.tables.records.SequenceTestRecord,
java.lang.Integer> ID = createField("id",
org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaulted(true), this);
 ...
}

Again, this should be correct because id is a serial/integer column. In my
opinion, this is a postgres "problem" because postgres uses 8 byte values
for a 4 byte column.

On the other hand, when using insertInto(MY_TABLE,
MY_TABLE.ID<http://my_table.id/>,
>> ...).values(MY_TABLE_ID_SEQ.nextval(), ...) statements, the types clash
>> because jooq expects a Field[Integer] but only finds a Field[Long]. One
>> solution would be to always use bigserials so is this the way to go?
>>
>
> Another solution is to omit the ID field in INSERT statements, as it is
> auto-generated by PostgreSQL...
>
Oh.... You're absolutely right. That is MUCH easier. Thanks!!

Julian

-- 
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/groups/opt_out.

Reply via email to