tk.mybatis.mapper.entity.Config Java Examples
The following examples show how to use
tk.mybatis.mapper.entity.Config.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapperHelper.java From Mapper with MIT License | 6 votes |
/** * 设置通用Mapper配置 * * @param config */ public void setConfig(Config config) { this.config = config; if(config.getResolveClass() != null){ try { EntityHelper.setResolve(config.getResolveClass().newInstance()); } catch (Exception e) { log.error("创建 " + config.getResolveClass().getCanonicalName() + " 实例失败,请保证该类有默认的构造方法!", e); throw new MapperException("创建 " + config.getResolveClass().getCanonicalName() + " 实例失败,请保证该类有默认的构造方法!", e); } } if(config.getMappers() != null && config.getMappers().size() > 0){ for (Class mapperClass : config.getMappers()) { registerMapper(mapperClass); } } }
Example #2
Source File: ColumnTest.java From Mapper with MIT License | 5 votes |
@Before public void beforeTest(){ config = new Config(); config.setStyle(Style.normal); configuration = new Configuration(); }
Example #3
Source File: KeySqlTest.java From Mapper with MIT License | 5 votes |
@Before public void beforeTest(){ config = new Config(); config.setStyle(Style.normal); configuration = new Configuration(); }
Example #4
Source File: RegisterMapperTest.java From Mapper with MIT License | 5 votes |
@Before public void beforeTest(){ config = new Config(); config.setStyle(Style.normal); configuration = new Configuration(); }
Example #5
Source File: IdTest.java From Mapper with MIT License | 5 votes |
@Before public void beforeTest(){ config = new Config(); config.setStyle(Style.normal); configuration = new Configuration(); }
Example #6
Source File: NameStyleTest.java From Mapper with MIT License | 5 votes |
@Before public void beforeTest(){ config = new Config(); config.setStyle(Style.normal); configuration = new Configuration(); }
Example #7
Source File: EntityHelper.java From Mapper with MIT License | 5 votes |
/** * 初始化实体属性 * * @param entityClass * @param config */ public static synchronized void initEntityNameMap(Class<?> entityClass, Config config) { if (entityTableMap.get(entityClass) != null) { return; } //创建并缓存EntityTable EntityTable entityTable = resolve.resolveEntity(entityClass, config); entityTableMap.put(entityClass, entityTable); }
Example #8
Source File: VersionTest.java From Mapper with MIT License | 5 votes |
@Before public void beforeTest(){ config = new Config(); config.setStyle(Style.normal); configuration = new Configuration(); }
Example #9
Source File: ColumnTypeTest.java From Mapper with MIT License | 5 votes |
@Before public void beforeTest(){ config = new Config(); config.setStyle(Style.normal); configuration = new Configuration(); }
Example #10
Source File: IdListMapperTest.java From Mapper with MIT License | 5 votes |
@Override protected Config getConfig() { Config config = super.getConfig(); //安全删除 config.setSafeDelete(true); return config; }
Example #11
Source File: GeneratedValueTest.java From Mapper with MIT License | 5 votes |
@Override protected Config getConfig() { Config config = super.getConfig(); config.setOrder("AFTER"); config.setIDENTITY("MYSQL"); return config; }
Example #12
Source File: SafeUpdateByMethodTest.java From Mapper with MIT License | 5 votes |
@Override protected Config getConfig() { Config config = super.getConfig(); config.setSafeUpdate(true); //和 SafeUpdateByFieldTest 测试的区别在此,这里将会使后面调用 EntityField.getValue 时,使用 getter 方法获取值 config.setEnableMethodAnnotation(true); return config; }
Example #13
Source File: SafeDeleteByMethodTest.java From Mapper with MIT License | 5 votes |
@Override protected Config getConfig() { Config config = super.getConfig(); config.setSafeDelete(true); //和 SafeDeleteByFieldTest 测试的区别在此,这里将会使后面调用 EntityField.getValue 时,使用 getter 方法获取值 config.setEnableMethodAnnotation(true); return config; }
Example #14
Source File: ClassPathMapperScanner.java From mapper-boot-starter with MIT License | 5 votes |
/** * 从环境变量中获取 mapper 配置信息 * * @param environment */ public void setMapperProperties(Environment environment) { Config config = SpringBootBindUtil.bind(environment, Config.class, Config.PREFIX); if (config != null) { mapperHelper.setConfig(config); } }
Example #15
Source File: ClassPathMapperScanner.java From mapper-boot-starter with MIT License | 5 votes |
/** * 从环境变量中获取 mapper 配置信息 * * @param environment */ public void setMapperProperties(Environment environment) { Config config = SpringBootBindUtil.bind(environment, Config.class, Config.PREFIX); if (config != null) { mapperHelper.setConfig(config); } }
Example #16
Source File: ComplexEntityTest.java From Mapper with MIT License | 5 votes |
@Before public void beforeTest() { config = new Config(); config.setStyle(Style.camelhump); configuration = new Configuration(); }
Example #17
Source File: TypeHandlerTest2.java From Mapper with MIT License | 4 votes |
@Override protected Config getConfig() { Config config = super.getConfig(); config.setEnumAsSimpleType(true); return config; }
Example #18
Source File: TypeHandlerTest.java From Mapper with MIT License | 4 votes |
@Override protected Config getConfig() { Config config = super.getConfig(); config.setEnumAsSimpleType(true); return config; }
Example #19
Source File: DefaultEnumTypeHandlerTest.java From Mapper with MIT License | 4 votes |
@Override protected Config getConfig() { Config config = super.getConfig(); config.setEnumAsSimpleType(true); return config; }
Example #20
Source File: SqlHelperTest.java From Mapper with MIT License | 4 votes |
@Before public void beforeTest() { config = new Config(); config.setStyle(Style.normal); EntityHelper.initEntityNameMap(User.class, config); }
Example #21
Source File: DefaultEntityResolve.java From Mapper with MIT License | 4 votes |
/** * 处理字段 * * @param entityTable * @param field * @param config * @param style */ protected void processField(EntityTable entityTable, EntityField field, Config config, Style style) { //排除字段 if (field.isAnnotationPresent(Transient.class)) { return; } //Id EntityColumn entityColumn = new EntityColumn(entityTable); //是否使用 {xx, javaType=xxx} entityColumn.setUseJavaType(config.isUseJavaType()); //记录 field 信息,方便后续扩展使用 entityColumn.setEntityField(field); if (field.isAnnotationPresent(Id.class)) { entityColumn.setId(true); } //Column String columnName = null; if (field.isAnnotationPresent(Column.class)) { Column column = field.getAnnotation(Column.class); columnName = column.name(); entityColumn.setUpdatable(column.updatable()); entityColumn.setInsertable(column.insertable()); } //ColumnType if (field.isAnnotationPresent(ColumnType.class)) { ColumnType columnType = field.getAnnotation(ColumnType.class); //是否为 blob 字段 entityColumn.setBlob(columnType.isBlob()); //column可以起到别名的作用 if (StringUtil.isEmpty(columnName) && StringUtil.isNotEmpty(columnType.column())) { columnName = columnType.column(); } if (columnType.jdbcType() != JdbcType.UNDEFINED) { entityColumn.setJdbcType(columnType.jdbcType()); } if (columnType.typeHandler() != UnknownTypeHandler.class) { entityColumn.setTypeHandler(columnType.typeHandler()); } } //列名 if (StringUtil.isEmpty(columnName)) { columnName = StringUtil.convertByStyle(field.getName(), style); } //自动处理关键字 if (StringUtil.isNotEmpty(config.getWrapKeyword()) && SqlReservedWords.containsWord(columnName)) { columnName = MessageFormat.format(config.getWrapKeyword(), columnName); } entityColumn.setProperty(field.getName()); entityColumn.setColumn(columnName); entityColumn.setJavaType(field.getJavaType()); if (field.getJavaType().isPrimitive()) { log.warn("通用 Mapper 警告信息: <[" + entityColumn + "]> 使用了基本类型,基本类型在动态 SQL 中由于存在默认值,因此任何时候都不等于 null,建议修改基本类型为对应的包装类型!"); } //OrderBy processOrderBy(entityTable, field, entityColumn); //处理主键策略 processKeyGenerator(entityTable, field, entityColumn); entityTable.getEntityClassColumns().add(entityColumn); if (entityColumn.isId()) { entityTable.getEntityClassPKColumns().add(entityColumn); } }
Example #22
Source File: SafeUpdateByFieldTest.java From Mapper with MIT License | 4 votes |
@Override protected Config getConfig() { Config config = super.getConfig(); config.setSafeUpdate(true); return config; }
Example #23
Source File: MapperTemplate.java From Mapper with MIT License | 4 votes |
public Config getConfig() { return mapperHelper.getConfig(); }
Example #24
Source File: TableTest.java From Mapper with MIT License | 4 votes |
@Before public void beforeTest() { config = new Config(); config.setStyle(Style.normal); }
Example #25
Source File: SafeDeleteByFieldTest.java From Mapper with MIT License | 4 votes |
@Override protected Config getConfig() { Config config = super.getConfig(); config.setSafeDelete(true); return config; }
Example #26
Source File: EntityResolve.java From Mapper with MIT License | 2 votes |
/** * 解析类为 EntityTable * * @param entityClass * @param config * @return */ EntityTable resolveEntity(Class<?> entityClass, Config config);
Example #27
Source File: MapperHelper.java From Mapper with MIT License | 2 votes |
/** * 获取通用Mapper配置 * * @return */ public Config getConfig() { return config; }
Example #28
Source File: MapperHelper.java From tk-mybatis with MIT License | 2 votes |
/** * 获取通用Mapper配置 * * @return */ public Config getConfig() { return config; }
Example #29
Source File: BaseTest.java From Mapper with MIT License | 2 votes |
/** * 获取 Mapper 配置 * * @return */ protected Config getConfig(){ return new Config(); }
Example #30
Source File: BaseTest.java From Mapper with MIT License | 2 votes |
/** * 获取 Mapper 配置 * * @return */ protected Config getConfig(){ return new Config(); }