-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Automatic schema creation defaults timestamp precision to 0
PostPosted: Mon Jul 18, 2016 2:23 pm 
Newbie

Joined: Mon Jul 18, 2016 2:00 pm
Posts: 2
I'm using hibernate automatic schema generation on my project with hibernate 5.0.1, MySQL 5.6.27 and Java 1.8.45
Everything works perfectly well, except for datetime / timestamp fields with with milliseconds. My fields annotations look like this:
Code:
    @Column(name = "transition_timestamp", scale=3)
    @Type(type="timestamp")
    private Timestamp transitionTimestamp;


I've also tried to use length=3 and precision=3 in multiple combinations with scale=3 and nothing seems to work as I expect. The only way I can make this work, is by adding the non-portable:
Code:
    @Column(name = "transition_timestamp", columnDefinition="datetime(3)")
    private Timestamp transitionTimestamp;


Am I missing something or should I report this as a bug?
I've tried upgrading hibernate to v5.2.1, just in case, but I still get the same behaviour.


Top
 Profile  
 
 Post subject: Re: Automatic schema creation defaults timestamp precision to 0
PostPosted: Tue Jul 19, 2016 9:04 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You should try the MySQL57InnoDBDialect because it registers Timestamp like this:

Code:
registerColumnType( Types.TIMESTAMP, "datetime(6)" );


Top
 Profile  
 
 Post subject: Re: Automatic schema creation defaults timestamp precision to 0
PostPosted: Tue Jul 19, 2016 9:31 am 
Newbie

Joined: Mon Jul 18, 2016 2:00 pm
Posts: 2
mihalcea_vlad wrote:
You should try the MySQL57InnoDBDialect because it registers Timestamp like this:

Code:
registerColumnType( Types.TIMESTAMP, "datetime(6)" );

It worked like a charm, thanks!


Top
 Profile  
 
 Post subject: Re: Automatic schema creation defaults timestamp precision to 0
PostPosted: Tue Jul 19, 2016 9:55 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You're welcome.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.