population of a timestamp column with milliseconds

69 views
Skip to first unread message

Klaus wOrst

unread,
Mar 14, 2017, 2:41:31 PM3/14/17
to Querydsl
Hi,

i face a problem when i need to insert a timestamp with milliseconds into a oracle db. The console output show a timestamp with milliseconds, but the inserted timestamp have no milliseconds. U can see a SQLListener with the prefix "Query:" which shows the sql-statement of the insert. This insert statement have no milliseconds at all.

timestamp = 2017-03-14 17:54:36.084
Query: insert into WSM_KOMMUNIKATIONEN (ID, DEPL_ID, BEGINN_TIMESTAMP) values (13602, 1, timestamp '2017-03-14 17:54:36') executed in 47 miliseconds
Query: select * from (   select qk.BEGINN_TIMESTAMP from WSM_KOMMUNIKATIONEN qk where qk.ID = 13602 ) where rownum <= 2 executed in 15 miliseconds
Timestamp @ db = 2017-03-14 17:54:36.0

Here the code:
        configuration.addListener(new PrintStreamSQLListener());
        SQLQueryFactory factory = new SQLQueryFactory(configuration, dataSource);
        QKommunikationen qk = new QKommunikationen("qk");
        Long id = ThreadLocalRandom.current().nextLong(1000, 20000 + 1);


        DateTime dateTime = new DateTime();
        Timestamp timestamp = new Timestamp(dateTime.getMillis());
        System.out.println("timestamp = " + timestamp);


        factory.insert(qk).columns(qk.id, qk.deplId, qk.beginnTimestamp).values(id, 1L, timestamp).execute();

        Timestamp dbTimestamp = factory.select(qk.beginnTimestamp).from(qk).where(qk.id.eq(id)).fetchOne();

        factory.delete(qk).where(qk.id.eq(id));

        factory.getConnection().commit();
        factory.getConnection().close();

        System.out.println("Timestamp @ db = " + dbTimestamp);

And a snippet of QKommunikationen with the timestamp column:

    public final DateTimePath<java.sql.Timestamp> beginnTimestamp = createDateTime("beginnTimestamp", java.sql.Timestamp.class);


I have no idea how to solve this issue. And hope u guys can help me to fix this.

Greetings w0rst

Klaus wOrst

unread,
Apr 2, 2017, 5:46:27 AM4/2/17
to Querydsl
have nobody an idea?

Bruno Rosa

unread,
May 5, 2017, 5:14:40 AM5/5/17
to Querydsl
Hi,

I had a similar issue, solved it by using the following configuration configuration.setUseLiterals(false); on my querydsl configuration (com.querydsl.sql.Configuration).

Hope it helps.

Regards,
Bruno

domingo, 2 de Abril de 2017 às 10:46:27 UTC+1, Klaus wOrst escreveu:
have nobody an idea?
Reply all
Reply to author
Forward
0 new messages