Java Code Examples for tk.mybatis.mapper.entity.EntityTable#getEntityClassColumns()
The following examples show how to use
tk.mybatis.mapper.entity.EntityTable#getEntityClassColumns() .
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: IdTest.java From Mapper with MIT License | 6 votes |
@Test public void testSingleId(){ EntityHelper.initEntityNameMap(UserSingleId.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserSingleId.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertTrue(column.isId()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals(1, resultMap.getResultMappings().size()); Assert.assertTrue(resultMap.getResultMappings().get(0).getFlags().contains(ResultFlag.ID)); Assert.assertEquals("<where> AND name = #{name}</where>", SqlHelper.wherePKColumns(UserSingleId.class)); }
Example 2
Source File: IdTest.java From Mapper with MIT License | 6 votes |
@Test public void testCompositeKeys(){ EntityHelper.initEntityNameMap(UserCompositeKeys.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserCompositeKeys.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(2, columns.size()); Assert.assertEquals(2, entityTable.getEntityClassPKColumns().size()); for (EntityColumn column : columns) { Assert.assertTrue(column.isId()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals(2, resultMap.getResultMappings().size()); Assert.assertTrue(resultMap.getResultMappings().get(0).getFlags().contains(ResultFlag.ID)); Assert.assertTrue(resultMap.getResultMappings().get(1).getFlags().contains(ResultFlag.ID)); Assert.assertEquals("<where> AND name = #{name} AND orgId = #{orgId}</where>", SqlHelper.wherePKColumns(UserCompositeKeys.class)); }
Example 3
Source File: EntityHelper.java From tk-mybatis with MIT License | 6 votes |
/** * 获取默认的orderby语句 * * @param entityClass * @return */ public static String getOrderByClause(Class<?> entityClass) { EntityTable table = getEntityTable(entityClass); if (table.getOrderByClause() != null) { return table.getOrderByClause(); } StringBuilder orderBy = new StringBuilder(); for (EntityColumn column : table.getEntityClassColumns()) { if (column.getOrderBy() != null) { if (orderBy.length() != 0) { orderBy.append(","); } orderBy.append(column.getColumn()).append(" ").append(column.getOrderBy()); } } table.setOrderByClause(orderBy.toString()); return table.getOrderByClause(); }
Example 4
Source File: KeySqlTest.java From Mapper with MIT License | 5 votes |
@Test public void testDialect(){ EntityHelper.initEntityNameMap(UserDialect.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserDialect.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("SELECT LAST_INSERT_ID()", column.getGenerator()); Assert.assertEquals(ORDER.AFTER, column.getOrder()); Assert.assertTrue(column.isIdentity()); } }
Example 5
Source File: ColumnTypeTest.java From Mapper with MIT License | 5 votes |
@Test public void testAll(){ EntityHelper.initEntityNameMap(UserAll.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserAll.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("user_name", column.getColumn()); Assert.assertEquals("name", column.getProperty()); Assert.assertEquals("user_name = #{name, jdbcType=BLOB, typeHandler=org.apache.ibatis.type.BlobTypeHandler}", column.getColumnEqualsHolder()); Assert.assertEquals("user_name = #{record.name, jdbcType=BLOB, typeHandler=org.apache.ibatis.type.BlobTypeHandler}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{name, jdbcType=BLOB, typeHandler=org.apache.ibatis.type.BlobTypeHandler}", column.getColumnHolder()); Assert.assertEquals("#{record.name, jdbcType=BLOB, typeHandler=org.apache.ibatis.type.BlobTypeHandler}", column.getColumnHolder("record")); Assert.assertEquals("#{record.name, jdbcType=BLOB, typeHandler=org.apache.ibatis.type.BlobTypeHandler}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.namesuffix, jdbcType=BLOB, typeHandler=org.apache.ibatis.type.BlobTypeHandler},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNotNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[USER_NAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("user_name", resultMapping.getColumn()); Assert.assertEquals("name", resultMapping.getProperty()); Assert.assertNotNull(resultMapping.getJdbcType()); Assert.assertEquals(BlobTypeHandler.class, resultMapping.getTypeHandler().getClass()); }
Example 6
Source File: ColumnTypeTest.java From Mapper with MIT License | 5 votes |
@Test public void testTypehandler(){ EntityHelper.initEntityNameMap(UserTypehandler.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserTypehandler.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("name", column.getColumn()); Assert.assertEquals("name", column.getProperty()); Assert.assertEquals("name = #{name, typeHandler=org.apache.ibatis.type.BlobTypeHandler}", column.getColumnEqualsHolder()); Assert.assertEquals("name = #{record.name, typeHandler=org.apache.ibatis.type.BlobTypeHandler}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{name, typeHandler=org.apache.ibatis.type.BlobTypeHandler}", column.getColumnHolder()); Assert.assertEquals("#{record.name, typeHandler=org.apache.ibatis.type.BlobTypeHandler}", column.getColumnHolder("record")); Assert.assertEquals("#{record.name, typeHandler=org.apache.ibatis.type.BlobTypeHandler}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.namesuffix, typeHandler=org.apache.ibatis.type.BlobTypeHandler},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNotNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[NAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("name", resultMapping.getColumn()); Assert.assertEquals("name", resultMapping.getProperty()); Assert.assertNull(resultMapping.getJdbcType()); Assert.assertEquals(BlobTypeHandler.class, resultMapping.getTypeHandler().getClass()); }
Example 7
Source File: ColumnTypeTest.java From Mapper with MIT License | 5 votes |
@Test public void testJdbcTypeBlob(){ EntityHelper.initEntityNameMap(UserJdbcTypeBlob.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserJdbcTypeBlob.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("name", column.getColumn()); Assert.assertEquals("name", column.getProperty()); Assert.assertEquals("name = #{name, jdbcType=BLOB}", column.getColumnEqualsHolder()); Assert.assertEquals("name = #{record.name, jdbcType=BLOB}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{name, jdbcType=BLOB}", column.getColumnHolder()); Assert.assertEquals("#{record.name, jdbcType=BLOB}", column.getColumnHolder("record")); Assert.assertEquals("#{record.name, jdbcType=BLOB}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.namesuffix, jdbcType=BLOB},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[NAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("name", resultMapping.getColumn()); Assert.assertEquals("name", resultMapping.getProperty()); Assert.assertNotNull(resultMapping.getJdbcType()); Assert.assertEquals(JdbcType.BLOB, resultMapping.getJdbcType()); Assert.assertEquals(StringTypeHandler.class, resultMapping.getTypeHandler().getClass()); }
Example 8
Source File: ColumnTypeTest.java From Mapper with MIT License | 5 votes |
@Test public void testJdbcTypeVarchar(){ EntityHelper.initEntityNameMap(UserJdbcTypeVarchar.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserJdbcTypeVarchar.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("name", column.getColumn()); Assert.assertEquals("name", column.getProperty()); Assert.assertEquals("name = #{name, jdbcType=VARCHAR}", column.getColumnEqualsHolder()); Assert.assertEquals("name = #{record.name, jdbcType=VARCHAR}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{name, jdbcType=VARCHAR}", column.getColumnHolder()); Assert.assertEquals("#{record.name, jdbcType=VARCHAR}", column.getColumnHolder("record")); Assert.assertEquals("#{record.name, jdbcType=VARCHAR}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.namesuffix, jdbcType=VARCHAR},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[NAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("name", resultMapping.getColumn()); Assert.assertEquals("name", resultMapping.getProperty()); Assert.assertNotNull(resultMapping.getJdbcType()); Assert.assertEquals(JdbcType.VARCHAR, resultMapping.getJdbcType()); Assert.assertEquals(StringTypeHandler.class, resultMapping.getTypeHandler().getClass()); }
Example 9
Source File: ColumnTypeTest.java From Mapper with MIT License | 5 votes |
@Test public void testColumn(){ EntityHelper.initEntityNameMap(UserColumn.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserColumn.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("user_name", column.getColumn()); Assert.assertEquals("name", column.getProperty()); Assert.assertEquals("user_name = #{name}", column.getColumnEqualsHolder()); Assert.assertEquals("user_name = #{record.name}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{name}", column.getColumnHolder()); Assert.assertEquals("#{record.name}", column.getColumnHolder("record")); Assert.assertEquals("#{record.name}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.namesuffix},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[USER_NAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("user_name", resultMapping.getColumn()); Assert.assertEquals("name", resultMapping.getProperty()); Assert.assertNull(resultMapping.getJdbcType()); Assert.assertEquals(StringTypeHandler.class, resultMapping.getTypeHandler().getClass()); }
Example 10
Source File: VersionTest.java From Mapper with MIT License | 5 votes |
@Test public void testVersion(){ EntityHelper.initEntityNameMap(UserVersion.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserVersion.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertTrue(column.getEntityField().isAnnotationPresent(Version.class)); } }
Example 11
Source File: KeySqlTest.java From Mapper with MIT License | 5 votes |
@Test public void testAll2(){ EntityHelper.initEntityNameMap(UserAll2.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserAll2.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("SELECT LAST_INSERT_ID()", column.getGenerator()); Assert.assertEquals(ORDER.AFTER, column.getOrder()); Assert.assertTrue(column.isIdentity()); } }
Example 12
Source File: KeySqlTest.java From Mapper with MIT License | 5 votes |
@Test public void testAll(){ EntityHelper.initEntityNameMap(UserAll.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserAll.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("JDBC", column.getGenerator()); Assert.assertTrue(column.isIdentity()); } }
Example 13
Source File: KeySqlTest.java From Mapper with MIT License | 5 votes |
@Test public void testSql(){ EntityHelper.initEntityNameMap(UserSql.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserSql.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("select seq.nextval from dual", column.getGenerator()); Assert.assertEquals(ORDER.BEFORE, column.getOrder()); Assert.assertTrue(column.isIdentity()); } }
Example 14
Source File: KeySqlTest.java From Mapper with MIT License | 5 votes |
@Test public void testUseGeneratedKeys(){ EntityHelper.initEntityNameMap(UserJDBC.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserJDBC.class); Assert.assertNotNull(entityTable); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("JDBC", column.getGenerator()); Assert.assertTrue(column.isIdentity()); } }
Example 15
Source File: NameStyleTest.java From Mapper with MIT License | 5 votes |
@Test public void testLowercase(){ EntityHelper.initEntityNameMap(UserLowercase.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserLowercase.class); Assert.assertNotNull(entityTable); Assert.assertEquals("userlowercase", entityTable.getName()); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("username", column.getColumn()); Assert.assertEquals("userName", column.getProperty()); Assert.assertEquals("username = #{userName}", column.getColumnEqualsHolder()); Assert.assertEquals("username = #{record.userName}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{userName}", column.getColumnHolder()); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record")); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.userNamesuffix},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[USERNAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("username", resultMapping.getColumn()); Assert.assertEquals("userName", resultMapping.getProperty()); Assert.assertNull(resultMapping.getJdbcType()); Assert.assertEquals(StringTypeHandler.class, resultMapping.getTypeHandler().getClass()); }
Example 16
Source File: NameStyleTest.java From Mapper with MIT License | 5 votes |
@Test public void testUppercase(){ EntityHelper.initEntityNameMap(UserUppercase.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserUppercase.class); Assert.assertNotNull(entityTable); Assert.assertEquals("USERUPPERCASE", entityTable.getName()); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("USERNAME", column.getColumn()); Assert.assertEquals("userName", column.getProperty()); Assert.assertEquals("USERNAME = #{userName}", column.getColumnEqualsHolder()); Assert.assertEquals("USERNAME = #{record.userName}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{userName}", column.getColumnHolder()); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record")); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.userNamesuffix},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[USERNAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("USERNAME", resultMapping.getColumn()); Assert.assertEquals("userName", resultMapping.getProperty()); Assert.assertNull(resultMapping.getJdbcType()); Assert.assertEquals(StringTypeHandler.class, resultMapping.getTypeHandler().getClass()); }
Example 17
Source File: NameStyleTest.java From Mapper with MIT License | 5 votes |
@Test public void testNormal(){ EntityHelper.initEntityNameMap(UserNormal.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserNormal.class); Assert.assertNotNull(entityTable); Assert.assertEquals("UserNormal", entityTable.getName()); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("userName", column.getColumn()); Assert.assertEquals("userName", column.getProperty()); Assert.assertEquals("userName = #{userName}", column.getColumnEqualsHolder()); Assert.assertEquals("userName = #{record.userName}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{userName}", column.getColumnHolder()); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record")); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.userNamesuffix},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[USERNAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("userName", resultMapping.getColumn()); Assert.assertEquals("userName", resultMapping.getProperty()); Assert.assertNull(resultMapping.getJdbcType()); Assert.assertEquals(StringTypeHandler.class, resultMapping.getTypeHandler().getClass()); }
Example 18
Source File: NameStyleTest.java From Mapper with MIT License | 5 votes |
@Test public void testCamelhumpAndLowercase(){ EntityHelper.initEntityNameMap(UserCamelhumpAndLowercase.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserCamelhumpAndLowercase.class); Assert.assertNotNull(entityTable); Assert.assertEquals("user_camelhump_and_lowercase", entityTable.getName()); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("user_name", column.getColumn()); Assert.assertEquals("userName", column.getProperty()); Assert.assertEquals("user_name = #{userName}", column.getColumnEqualsHolder()); Assert.assertEquals("user_name = #{record.userName}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{userName}", column.getColumnHolder()); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record")); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.userNamesuffix},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[USER_NAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("user_name", resultMapping.getColumn()); Assert.assertEquals("userName", resultMapping.getProperty()); Assert.assertNull(resultMapping.getJdbcType()); Assert.assertEquals(StringTypeHandler.class, resultMapping.getTypeHandler().getClass()); }
Example 19
Source File: NameStyleTest.java From Mapper with MIT License | 5 votes |
@Test public void testCamelhumpAndUppercase(){ EntityHelper.initEntityNameMap(UserCamelhumpAndUppercase.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserCamelhumpAndUppercase.class); Assert.assertNotNull(entityTable); Assert.assertEquals("USER_CAMELHUMP_AND_UPPERCASE", entityTable.getName()); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("USER_NAME", column.getColumn()); Assert.assertEquals("userName", column.getProperty()); Assert.assertEquals("USER_NAME = #{userName}", column.getColumnEqualsHolder()); Assert.assertEquals("USER_NAME = #{record.userName}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{userName}", column.getColumnHolder()); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record")); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.userNamesuffix},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[USER_NAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("USER_NAME", resultMapping.getColumn()); Assert.assertEquals("userName", resultMapping.getProperty()); Assert.assertNull(resultMapping.getJdbcType()); Assert.assertEquals(StringTypeHandler.class, resultMapping.getTypeHandler().getClass()); }
Example 20
Source File: NameStyleTest.java From Mapper with MIT License | 5 votes |
@Test public void testCamelhump(){ EntityHelper.initEntityNameMap(UserCamelhump.class, config); EntityTable entityTable = EntityHelper.getEntityTable(UserCamelhump.class); Assert.assertNotNull(entityTable); Assert.assertEquals("user_camelhump", entityTable.getName()); Set<EntityColumn> columns = entityTable.getEntityClassColumns(); Assert.assertEquals(1, columns.size()); for (EntityColumn column : columns) { Assert.assertEquals("user_name", column.getColumn()); Assert.assertEquals("userName", column.getProperty()); Assert.assertEquals("user_name = #{userName}", column.getColumnEqualsHolder()); Assert.assertEquals("user_name = #{record.userName}", column.getColumnEqualsHolder("record")); Assert.assertEquals("#{userName}", column.getColumnHolder()); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record")); Assert.assertEquals("#{record.userName}", column.getColumnHolder("record", "suffix")); Assert.assertEquals("#{record.userNamesuffix},", column.getColumnHolder("record", "suffix", ",")); Assert.assertNull(column.getTypeHandler()); } ResultMap resultMap = entityTable.getResultMap(configuration); Assert.assertEquals("[USER_NAME]", resultMap.getMappedColumns().toString()); Assert.assertEquals(1, resultMap.getResultMappings().size()); ResultMapping resultMapping = resultMap.getResultMappings().get(0); Assert.assertEquals("user_name", resultMapping.getColumn()); Assert.assertEquals("userName", resultMapping.getProperty()); Assert.assertNull(resultMapping.getJdbcType()); Assert.assertEquals(StringTypeHandler.class, resultMapping.getTypeHandler().getClass()); }