You might try creating your own function.
public Field<DateTime> now() {
return DSL.function("now", DateTime.class);
}
-
Mike Foody
Providence HR
http://www.providencehr.com
(832) 714 1652
[email protected]
On Wed, Dec 7, 2016 at 7:53 PM, Samir Faci <[email protected]> wrote:
> You could also use
>
> DSL.currentDate()
> DSL.currentTime()
> DSL.currentTimestamp();
>
> Based on your code snippet I assume you probably want
> DSL.currentTimestamp().
>
>
> Probably a bit prettier then relying on field("...")
>
>
>
>
> On Wed, Dec 7, 2016 at 2:35 PM, Anthony Calce <[email protected]>
> wrote:
>
>> I've found a solution, but it's not very pretty
>> Collection<Object> x = new ArrayList<Object>();
>> x.add(1);
>> x.add(DSL.field("NOW()", Timestamp.class));
>>
>> try (KrJooqWrapper wrapper = new KrJooqWrapper(DbType.KRDB,
>> true)){
>> wrapper.getCreate()
>> .insertInto(
>> CUSTOMER,
>> CUSTOMER.ACCOUNT_NUMBER,
>> CUSTOMER.CANCEL_DATE)
>> .values(
>> x
>> )
>> .execute();
>> }
>>
>> Notice how I had to use Timestamp. If I use DateTime in that field type,
>> I get the following error "Type class org.joda.time.DateTime is not
>> supported in dialect DEFAULT". This solution isn't too appealing since I
>> lose type information for the values. Any alternatives?
>>
>>
>>
>> On Wednesday, 7 December 2016 16:46:55 UTC-5, Anthony Calce wrote:
>>>
>>> Hey Lukas,
>>>
>>> Is it possible to use "NOW()" in an insert function. For example, the
>>> insert is to look like this
>>>
>>> INSERT INTO db.customer(
>>> account_number,
>>> cancel_date
>>> )
>>> VALUES (
>>> 1,
>>> NOW()
>>> )
>>>
>>> The Jooq Query will look like
>>> wrapper.getCreate()
>>> .insertInto(
>>> CUSTOMER,
>>> CUSTOMER.ACCOUNT_NUMBER, // int
>>> CUSTOMER.CANCEL_DATE) // joda DateTime
>>> .values(
>>> 1,
>>> SOMETHING); // What should this be
>>> )
>>> .execute();
>>>
>>> I use a type converter from Timestamp to DateTime. The problem is that
>>> the insert is expecting a DateTime object. I could use *new DateTime(),
>>> *but I want to use the MYSQL server time for this. The following don't
>>> work
>>>
>>> - DSL.val("NOW()") -> returns a string, type mismatch
>>> - DSL.field("NOW()", DateTime.class) -> returns a Field<DateTime>
>>> which isn't compatible
>>>
>>> Any ideas?
>>>
>> --
>> 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.
>>
>
>
>
> --
> Thank you
> Samir Faci
> https://keybase.io/csgeek
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "jOOQ User Group" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/jooq-user/7hfDlmEwfQI/unsubscribe.
> To unsubscribe from this group and all its topics, 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.