org.hibernate.type.LocalTimeType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core-jakarta Show documentation
Show all versions of hibernate-core-jakarta Show documentation
Hibernate O/RM implementation of the Jakarta Persistence specification
The newest version!
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.type;
import java.time.LocalTime;
import jakarta.persistence.TemporalType;
import org.hibernate.metamodel.model.domain.AllowableTemporalParameterType;
import org.hibernate.type.descriptor.java.LocalTimeJavaDescriptor;
import org.hibernate.type.descriptor.jdbc.TimeTypeDescriptor;
import org.hibernate.type.spi.TypeConfiguration;
/**
* A type that maps between {@link java.sql.Types#TIMESTAMP TIMESTAMP} and {@link java.time.LocalDateTime}.
*
* @author Steve Ebersole
*/
public class LocalTimeType
extends AbstractSingleColumnStandardBasicType
implements LiteralType, AllowableTemporalParameterType {
/**
* Singleton access
*/
public static final LocalTimeType INSTANCE = new LocalTimeType();
public LocalTimeType() {
super( TimeTypeDescriptor.INSTANCE, LocalTimeJavaDescriptor.INSTANCE );
}
@Override
public String getName() {
return LocalTime.class.getSimpleName();
}
@Override
protected boolean registerUnderJavaType() {
return true;
}
@Override
public AllowableTemporalParameterType resolveTemporalPrecision(
TemporalType temporalPrecision,
TypeConfiguration typeConfiguration) {
switch ( temporalPrecision ) {
case TIME: {
return this;
}
case TIMESTAMP: {
return LocalDateTimeType.INSTANCE;
}
case DATE: {
return LocalDateType.INSTANCE;
}
}
// Why Java? Why?
return null;
}
}