com.baomidou.mybatisplus.annotation.Version Java Examples
The following examples show how to use
com.baomidou.mybatisplus.annotation.Version.
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: MyBatisMetadata.java From jstarcraft-core with Apache License 2.0 | 4 votes |
/** * 构造方法 * * @param metadata */ MyBatisMetadata(Class<? extends BaseMapper<?>> clazz) { ormClass = Class.class.cast(ParameterizedType.class.cast(clazz.getGenericInterfaces()[0]).getActualTypeArguments()[0]); ormName = ormClass.getName(); ReflectionUtility.doWithFields(ormClass, (field) -> { if (Modifier.isStatic(field.getModifiers()) || Modifier.isTransient(field.getModifiers())) { return; } TableField annotation = field.getAnnotation(TableField.class); if (annotation != null) { if (!annotation.exist()) { return; } String columnName = annotation.value(); if (!StringUtility.isEmpty(columnName)) { columnNames.put(field.getName(), columnName); } } if (field.isAnnotationPresent(Version.class)) { versionName = field.getName(); return; } Class<?> type = ClassUtility.primitiveToWrapper(field.getType()); if (String.class == type) { fields.put(field.getName(), type); } else if (type.isEnum()) { fields.put(field.getName(), type); } else if (Collection.class.isAssignableFrom(type) || type.isArray()) { fields.put(field.getName(), List.class); } else if (Date.class.isAssignableFrom(type)) { fields.put(field.getName(), Date.class); } else { fields.put(field.getName(), Map.class); } if (field.isAnnotationPresent(TableId.class)) { primaryName = field.getName(); primaryClass = type; } }); mapperClass = clazz; }