Java Code Examples for org.mybatis.generator.api.IntrospectedTable#getPrimaryKeyType()

The following examples show how to use org.mybatis.generator.api.IntrospectedTable#getPrimaryKeyType() . 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: JavaElementGeneratorTools.java    From mybatis-generator-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * 获取Model没有BLOBs类时的类型
 * @param introspectedTable
 * @return
 */
public static FullyQualifiedJavaType getModelTypeWithoutBLOBs(IntrospectedTable introspectedTable) {
    FullyQualifiedJavaType type;
    if (introspectedTable.getRules().generateBaseRecordClass()) {
        type = new FullyQualifiedJavaType(introspectedTable.getBaseRecordType());
    } else if (introspectedTable.getRules().generatePrimaryKeyClass()) {
        type = new FullyQualifiedJavaType(introspectedTable.getPrimaryKeyType());
    } else {
        throw new RuntimeException(getString("RuntimeError.12"));
    }
    return type;
}
 
Example 2
Source File: AliasResultMapWithoutBLOBsElementGenerator.java    From maven-archetype with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * addElements: 在当前的parentElement元素中添加别名ReulstMap列元素. <br/>
 *
 * @author Hongbin Yuan			父元素,新的elements将作为子元素添加到该元素
 * @param parentElement
 * @param introspectedTable		当前表的信息
 * @since JDK 1.6
 */
public void addElements(XmlElement parentElement,IntrospectedTable introspectedTable) {
	XmlElement answer = new XmlElement("resultMap"); //$NON-NLS-1$
	
	introspectedTable.getContext().getCommentGenerator().addComment(answer);
	
	answer.addAttribute(new Attribute("id", resultMapId));
	String returnType = null;
	if (isSimple) {
		returnType = introspectedTable.getBaseRecordType();
	} else {
		if (introspectedTable.getRules().generateBaseRecordClass()) {
			returnType = introspectedTable.getBaseRecordType();
		} else {
			returnType = introspectedTable.getPrimaryKeyType();
		}
	}
	answer.addAttribute(new Attribute("type", //$NON-NLS-1$
			returnType));

	if (introspectedTable.isConstructorBased()) {
		addResultMapConstructorElements(answer,introspectedTable);
	} else {
		addResultMapElements(answer,introspectedTable);
	}
	
	parentElement.addElement(answer);
}