forked from zouzg/mybatis-generator-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request zouzg#182 from hanakeichen/master
JSR-310 support: Date and Time API
- Loading branch information
Showing
5 changed files
with
69 additions
and
0 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
45 changes: 45 additions & 0 deletions
45
src/main/java/com/zzg/mybatis/generator/plugins/JavaTypeResolverJsr310Impl.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,45 @@ | ||
package com.zzg.mybatis.generator.plugins; | ||
|
||
import org.mybatis.generator.api.IntrospectedColumn; | ||
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType; | ||
import org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl; | ||
|
||
import java.sql.Types; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
|
||
/** | ||
* @author hanakei | ||
* @since 2018/4/28 | ||
*/ | ||
public class JavaTypeResolverJsr310Impl extends JavaTypeResolverDefaultImpl { | ||
|
||
@Override | ||
protected FullyQualifiedJavaType overrideDefaultType(IntrospectedColumn column, FullyQualifiedJavaType defaultType) { | ||
FullyQualifiedJavaType answer = defaultType; | ||
|
||
switch (column.getJdbcType()) { | ||
case Types.BIT: | ||
answer = calculateBitReplacement(column, defaultType); | ||
break; | ||
case Types.DECIMAL: | ||
case Types.NUMERIC: | ||
answer = calculateBigDecimalReplacement(column, defaultType); | ||
break; | ||
case Types.DATE: | ||
answer = new FullyQualifiedJavaType(LocalDate.class.getName()); | ||
break; | ||
case Types.TIME: | ||
answer = new FullyQualifiedJavaType(LocalTime.class.getName()); | ||
break; | ||
case Types.TIMESTAMP: | ||
answer = new FullyQualifiedJavaType(LocalDateTime.class.getName()); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
return answer; | ||
} | ||
} |
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