7

I have an entity that has a variable of type LocalTime and I would like to store it in database. So I have two questions:

  1. What data type will the field in mysql be?
  2. What annotation to use for entity?

I do not care for date at all whatsoever.

Quillion
  • 6,346
  • 11
  • 60
  • 97

1 Answers1

10

hibernate-java8 provide a LocalTimeType for persist a LocalTime field.Since hibernate-java8-5.2.+ has been merged into the hibernate-core module.

Usage

saving LocalTime as sql time column.

@Column
private LocalTime time;

saving LocalTime as sql varchar column.

@Column(columnDefinition = "varchar(8)")
private LocalTime time;
holi-java
  • 29,655
  • 7
  • 72
  • 83