Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HHH-11773 - Add support for JDBC 4.2 type names
- Loading branch information
1 parent
7362a49
commit 33f05fe
Showing
35 changed files
with
985 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
hibernate-core/src/main/java/org/hibernate/type/TimeWithTimeZoneType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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 <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.type; | ||
|
||
import java.sql.Time; | ||
import java.time.OffsetTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Locale; | ||
|
||
import org.hibernate.dialect.Dialect; | ||
import org.hibernate.type.descriptor.java.OffsetTimeJavaDescriptor; | ||
import org.hibernate.type.descriptor.sql.TimeWithTimeZoneTypeDescriptor; | ||
|
||
/** | ||
* A type that maps between {@link java.sql.Types#TIME_WITH_TIMEZONE TIME_WITH_TIMEZONE} and {@link Time} | ||
* | ||
* @author Vlad Mihalcea | ||
*/ | ||
public class TimeWithTimeZoneType | ||
extends AbstractSingleColumnStandardBasicType<OffsetTime> | ||
implements LiteralType<OffsetTime> { | ||
|
||
public static final TimeWithTimeZoneType INSTANCE = new TimeWithTimeZoneType(); | ||
|
||
public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern( "HH:mm:ss.S xxxxx", Locale.ENGLISH ); | ||
|
||
public TimeWithTimeZoneType() { | ||
super( TimeWithTimeZoneTypeDescriptor.INSTANCE, OffsetTimeJavaDescriptor.INSTANCE ); | ||
} | ||
|
||
@Override | ||
public String objectToSQLString(OffsetTime value, Dialect dialect) throws Exception { | ||
return "{t '" + FORMATTER.format( value ) + "'}"; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "time_with_timezone"; | ||
} | ||
|
||
@Override | ||
protected boolean registerUnderJavaType() { | ||
return true; | ||
} | ||
} |
Oops, something went wrong.