Hello Timm,

Thanks again for reporting this. This is now fixed on github master for
jOOQ 3.0 and will be merged into jOOQ 2.6.1

Cheers
Lukas


2012/12/13 Lukas Eder <[email protected]>

> Hello Timm,
>
> I suspect that this issue is due to the fact that create.fieldByName()
> doesn't know the type of the column (hence, Object), and coerces that
> unknown type on the right hand side of the comparison predicate. That
> should be fixed in jOOQ. I have registered #2007 for this:
> https://github.com/jOOQ/jOOQ/issues/2007
>
> In the mean time, try explicitly setting the type on your field:
> create.fieldByName(Timestamp.class, "TEST_COLUMN").lessThan(now)
>
> Cheers
> Lukas
>
>
> 2012/12/13 Timm Baumeister <[email protected]>
>
>> Is it possible to bind a java sql timestamp within the generated query?
>>
>>
>>>          java.sql.Timestamp now = new java.sql.Timestamp(new
>>> Date().getTime());
>>> Settings settings = new Settings();
>>> settings.setStatementType(StatementType.STATIC_STATEMENT);
>>>  Connection con = DriverManager.getConnection(...);
>>> final Factory create = new OracleFactory(con,settings);
>>> Statement s = con.createStatement();
>>>  s.execute("drop table test_table");
>>> s.execute("create table test_table ( test_column DATE )");
>>> s.execute("insert into test_table values (to_date('20020315',
>>> 'yyyymmdd'))");
>>
>>                 final org.jooq.Table<org.jooq.Record> table =
>>> create.tableByName("TEST_TABLE");
>>>  final org.jooq.SelectSelectStep sss = create.select(create.count());
>>> final org.jooq.SelectJoinStep sjs = sss.from(table);
>>> final org.jooq.SelectConditionStep scs =
>>> sjs.where(create.fieldByName("TEST_COLUMN").lessThan(now));
>>
>>                 System.out.println(scs.toSQL());
>>
>>
>>>
>>
>> Generates
>>
>>                  select count(*) from "TEST_TABLE" where "TEST_COLUMN" <
>>> '2012-12-12 22:01:21.929'
>>
>>
>> How can I get the correct to_date conversion for  the variable now,
>> without having to use a prepared statement?
>>
>> Timm
>>
>
>

Reply via email to