Thanks for the reply...

The solution that u have given is accepted by eclipse compiler for
UpdateQuery<GameRecord> updateSC =
factory.updateQuery(Game.GAME);
                        updateSC.addValue(Game.END_TIME,
factory.currentTimestamp());
                        updateSC.addValue(Game.PLAY_TIME,
factory.plainSQLField("TIMESTAMPDIFF(SECOND,START_TIME,
END_TIME)",BigDecimal.class));
                        updateSC.addValue(Game.SCORE,score);
 
updateSC.addConditions(Game.GAME_ID.equal(scoreCardId));
                        updateSC.execute();

but this is yet not working... Is it not meant to work with this??

GameRecord =
factory.fetchOne(Game.GAME,Game.GAME_ID.equal(scoreCardId));
                        GameRecord.setValue(Game.END_TIME,
factory.currentTimestamp());
                        GameRecord.addValue(Game.PLAY_TIME,
factory.plainSQLField("TIMESTAMPDIFF(SECOND,START_TIME,
END_TIME)",BigDecimal.class));
                        GameRecord.setScore(score);
                        GameRecord.store();

The errors are..
--  for Game.END_TIME line
------------ The method addValue(StoreQuery<GameRecord>,
TableField<GameRecord,T>) in the type UpdatableRecordImpl<GameRecord>
is not applicable for the arguments (TableField<GameRecord,Timestamp>,
Field<Timestamp>)

-- for Game.PLAY_TIME line
------------ The method addValue(StoreQuery<GameRecord>,
TableField<GameRecord,T>) in the type UpdatableRecordImpl<GameRecord>
is not applicable for the arguments
(TableField<GameRecord,BigDecimal>, Field<BigDecimal>)

On Mar 26, 12:52 pm, Lukas Eder <[email protected]> wrote:
> Hi Shekhar,
>
> You're right, my example wasn't precise. jOOQ doesn't know the associated
> Java type of a plain SQL field, when you create it with
> Factory.plainSQLField(String). So that method will return Field<?>. On the
> other hand, if you know a reasonable type for your plain SQL field, then you
> can provide that type to jOOQ. Use this plainSQLField syntax instead:
>
> create.plainSQLField("TIMESTAMPDIFF(SECOND, START_TIME, END_TIME)"),
> Integer.class);
>
> Or replace the above Integer.class with BigInteger.class or
> BigDecimal.class, whatever matches Game.PLAY_TIME.getType().
> I will update the documentation page to explain 
> this:https://sourceforge.net/apps/trac/jooq/wiki/Manual/DSL/SQL
>
> Cheers
> Lukas
>
> 2011/3/26 Shekhar <[email protected]>
>
>
>
>
>
>
>
> > I am still having some doubts about the query -
>
> > update GAME set END_TIME=now(),
> > PLAY_TIME=TIMESTAMPDIFF(SECOND,START_TIME,END_TIME) where
> > GAME_ID="100001"
>
> > As you suggest,
> >                        UpdateQuery<GameRecord> updateSC =
> > factory.updateQuery(Game.GAME);
> >                        updateSC.addValue(Game.END_TIME,
> > factory.currentTimestamp());
> >                        updateSC.addValue(Game.PLAY_TIME,
> > factory.plainSQLField("TIMESTAMPDIFF(SECOND,START_TIME, END_TIME)"));
> >                        updateSC.addValue(Game.SCORE,score);
>
> >  updateSC.addConditions(Game.GAME_ID.equal(scoreCardId));
> >                        updateSC.execute();
>
> > OR here is what i want, since i want the record that is updated to
> > sent back to the user.
>
> >                        GameRecord =
> > factory.fetchOne(Game.GAME,Game.GAME_ID.equal(scoreCardId));
> >                        GameRecord.setValue(Game.END_TIME,
> > factory.currentTimestamp());
> >                        GameRecord.addValue(Game.PLAY_TIME,
> > factory.plainSQLField("TIMESTAMPDIFF(SECOND,START_TIME, END_TIME)"));
> >                        GameRecord.setScore(score);
> >                        GameRecord.store();
>
> > Both are showing the error for addValue Game.PLAY_TIME line...
> > The method addValue(StoreQuery<GameRecord>, TableField<GameRecord,T>)
> > in the type UpdatableRecordImpl<GameRecord> is not
> >  applicable for the arguments (TableField<GameRecord,BigDecimal>,
> > Field<capture#2-of ?>)
>
> > The second jooq query also shows an error in Game.END_TIME line..
> > The method setValue(Field<T>, T) in the type RecordImpl is not
> > applicable for the arguments (TableField<GameRecord,Timestamp>,
> > Field<Timestamp>)
>
> > Could you help?
>
> > I am sorry if i am wasting your precious time. I really don't have
> > much documentation about jOOQ

Reply via email to