mybatis-jpa-extra--MyBatis进行了扩展

MyBatisJPAExtra对MyBatis进行了扩展 , 目的在于简化开发的难度 , 采用了JPA2.1的注释 , 无需配置映射的XML文件 , 使用插件的方式动态生成SQL语句 , 实现对单表的操作的简化;另外使用Interceptor拦截需要分页的SELECT查询语句 , 根据不同的数据库完成分页查询 。
mybatis-jpa-extra--MyBatis进行了扩展
文章图片
1、JavaBean注释简单只支持4个注释
@Table@Id@Column@GeneratedValue
@GeneratedValue有3中策略
AUTOuuiduuid.hexserialSEQUENCEgenerator值为数据库序列名IDENTITYgenerator无 , 根据数据库自动生成方式【mybatis-jpa-extra--MyBatis进行了扩展】packageorg.apache.mybatis.jpa.test.domainimportjava.io.Serializableimportjavax.persistence.Columnimportjavax.persistence.GeneratedValueimportjavax.persistence.GenerationTypeimportjavax.persistence.Idimportjavax.persistence.Tableimportorg.apache.mybatis.jpa.persistence.JpaBaseDomain/*IDvarchar(40)notnull,NAMEvarchar(60)notnull,STATUSchar(1)null,CREATEBYvarchar(40)null,CREATEDATEdatenull,UPDATEBYvarchar(40)null,UPDATEDATEdatenull,constraintPK_ROLESprimarykeyclustered(ID)*//***@authorCrystal.Sea**/@Table(name="STUDENTS")publicclassStudentsextendsJpaBaseDomainimplementsSerializable{/****/privatestaticfinallongserialVersionUID=-6928570405840778151L@Id@Column@GeneratedValue(strategy=GenerationType.AUTO,generator="serial")//@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="SEQ_MYBATIS_STUD")//@GeneratedValue(strategy=GenerationType.IDENTITY,generator="SEQ_MYBATIS_STUD")privateStringid@ColumnprivateStringstdNo@ColumnprivateStringstdName@ColumnprivateStringstdGender@ColumnprivateintstdAge@ColumnprivateStringstdMajor@ColumnprivateStringstdClasspublicStudents(){super()}publicStringgetStdNo(){returnstdNo}publicvoidsetStdNo(StringstdNo){this.stdNo=stdNo}publicStringgetStdName(){returnstdName}publicvoidsetStdName(StringstdName){this.stdName=stdName}publicStringgetStdGender(){returnstdGender}publicvoidsetStdGender(StringstdGender){this.stdGender=stdGender}publicintgetStdAge(){returnstdAge}publicvoidsetStdAge(intstdAge){this.stdAge=stdAge}publicStringgetStdMajor(){returnstdMajor}publicvoidsetStdMajor(StringstdMajor){this.stdMajor=stdMajor}publicStringgetStdClass(){returnstdClass}publicvoidsetStdClass(StringstdClass){this.stdClass=stdClass}publicStringgetId(){returnid}publicvoidsetId(Stringid){this.id=id}@OverridepublicStringtoString(){return"Students[stdNo="+stdNo+",stdName="+stdName+",stdgender="+stdGender+",stdAge="+stdAge+",stdMajor="+stdMajor+",stdClass="+stdClass+"]


    推荐阅读