Using army annotations mapping pojo ChinaRegion to china_region table
// mapping domain to table
@Table(name = "china_region", indexes = {
@Index(name = "china_region_uni_name_region_type", fieldList = {"name", "regionType"}, unique = true),
@Index(name = "china_region_inx_parent_id", fieldList = "parentId")},
comment = "china region")
@Inheritance("regionType")
public class ChinaRegion<T extends ChinaRegion<T>> { // assume ChinaRegion exists sub class
@Generator(type = GeneratorType.POST) // id is generated by database
@Column
private Long id; // 'id' is army reserved field name,it representing primary key
@Column(scale = 2)
private LocalDateTime createTime; // 'createTime' is army reserved field name,it representing table record create time
// updateTime is optional field, if table is immutable
@Column
private LocalDateTime updateTime; // 'updateTime' is army reserved field name,it representing table record last update time
// version is optional field
@Column
private Integer version; // 'version' is army reserved field name,it representing table record's optimistic lock
// visible is optional field
@Column
private Boolean visible; // 'visible' is army reserved field name,it representing table record's soft delete
@Column
private RegionType regionType;
@Column(precision = 20, nullable = false, comment = "china region name")
private String name;
@Column(precision = 16, scale = 2, defaultValue = "0.00", nullable = false, comment = "china region GDP")
private BigDecimal regionGdp;
@Column(nullable = false, defaultValue = "0", updateMode = UpdateMode.IMMUTABLE, comment = "china region parent level id")
private Long parentId;
@Column(defaultValue = "0", nullable = false, comment = "china region population")
private Integer population;
}
io.army.modelgen.ArmyMetaModelDomainProcessor generate static metamodel class
// Army static metamodel class
@Generated(value = "io.army.modelgen.ArmyMetaModelDomainProcessor",
date = "2024-01-02 07:13:54.605524+08:00",
comments = "china region")
@SuppressWarnings("unchecked")
public abstract class ChinaRegion_ {
private ChinaRegion_() {
throw new UnsupportedOperationException();
}
public static final ParentTableMeta<ChinaRegion<?>> T;
/** Due to ChinaRegion<?> contains type parameter(s) , army generate static CLASS for army session query api. */
public static final Class<ChinaRegion<?>> CLASS = (Class<ChinaRegion<?>>) ((Class<?>) ChinaRegion.class);
static {
final ParentTableMeta<?> temp;
temp = _TableMetaFactory.getParentTableMeta(ChinaRegion.class);
T = (ParentTableMeta<ChinaRegion<?>>) temp;
final int fieldSize = T.fieldList().size();
if (fieldSize != 10) {
throw _TableMetaFactory.tableFiledSizeError(ChinaRegion.class,fieldSize);
}
}
/** Due to ChinaRegion<?> contains type parameter(s) , army generate static constructor method for army session query api. */
public static ChinaRegion<?> constructor() {
return new ChinaRegion<>();
}
/*-------------------following table filed names-------------------*/
/** {@link ChinaRegion#regionGdp } china region GDP */
public static final String REGION_GDP = "regionGdp";
/** {@link ChinaRegion#visible } visible for logic delete */
public static final String VISIBLE = "visible";
/** {@link ChinaRegion#regionType } @see io.army.example.bank.domain.user.RegionType */
public static final String REGION_TYPE = "regionType";
/** {@link ChinaRegion#createTime } create time */
public static final String CREATE_TIME = "createTime";
/** {@link ChinaRegion#name } china region name */
public static final String NAME = "name";
/** {@link ChinaRegion#updateTime } update time */
public static final String UPDATE_TIME = "updateTime";
/** {@link ChinaRegion#id } primary key */
public static final String ID = "id";
/** {@link ChinaRegion#version } version for optimistic lock */
public static final String VERSION = "version";
/** {@link ChinaRegion#parentId } china region parent level id */
public static final String PARENT_ID = "parentId";
/** {@link ChinaRegion#population } china region population */
public static final String POPULATION = "population";
/*-------------------following table filed metas-------------------*/
/** {@link ChinaRegion#regionGdp } china region GDP */
public static final FieldMeta<ChinaRegion<?>> regionGdp = T.getField(REGION_GDP);
/** {@link ChinaRegion#visible } visible for logic delete */
public static final FieldMeta<ChinaRegion<?>> visible = T.getField(VISIBLE);
/** {@link ChinaRegion#regionType } @see io.army.example.bank.domain.user.RegionType */
public static final FieldMeta<ChinaRegion<?>> regionType = T.getField(REGION_TYPE);
/** {@link ChinaRegion#createTime } create time */
public static final FieldMeta<ChinaRegion<?>> createTime = T.getField(CREATE_TIME);
/** {@link ChinaRegion#name } china region name */
public static final FieldMeta<ChinaRegion<?>> name = T.getField(NAME);
/** {@link ChinaRegion#updateTime } update time */
public static final FieldMeta<ChinaRegion<?>> updateTime = T.getField(UPDATE_TIME);
/** {@link ChinaRegion#id } primary key */
public static final PrimaryFieldMeta<ChinaRegion<?>> id = T.id();
/** {@link ChinaRegion#version } version for optimistic lock */
public static final FieldMeta<ChinaRegion<?>> version = T.getField(VERSION);
/** {@link ChinaRegion#parentId } china region parent level id */
public static final FieldMeta<ChinaRegion<?>> parentId = T.getField(PARENT_ID);
/** {@link ChinaRegion#population } china region population */
public static final FieldMeta<ChinaRegion<?>> population = T.getField(POPULATION);
} // ChinaRegion_
Army is a better blocking/reactive SQL framework
Design Philosophy
Army convention
Army document
How to start ?
Maven
appropriate maven module that contain domain class
Using army annotations mapping pojo ChinaRegion to china_region table
io.army.modelgen.ArmyMetaModelDomainProcessor generate static metamodel class
How to start test use case