tk.mybatis 调用oracle,生成ID
//配置類
@Configuration
public class IdConfig {
@Bean
public MapperScannerConfigurer mapperScannerConfigurer(){
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
mapperScannerConfigurer.setBasePackage("com.foxconn.svcapollo.mapper");
Properties propertiesMapper = new Properties(); //通用mapper位置,不要和其他mapper、dao放在同一个目录
propertiesMapper.setProperty("mappers", "com.foxconn.svcapollo.config.MyMapper");
propertiesMapper.setProperty("notEmpty", "false"); //主键UUID回写方法执行顺序,默认AFTER,可选值为(BEFORE|AFTER)
propertiesMapper.setProperty("ORDER","BEFORE");
mapperScannerConfigurer.setProperties(propertiesMapper);
return mapperScannerConfigurer;
}
}
//通用mapper配置類
public interface MyMapper<T> extends Mapper<T>,MySqlMapper<T> {
}
@Mapper
public interface ConsignmentDao2 extends MyMapper<Apo_Ack_Delivery_Line>{}
@Table(name="APO_ACK_DELIVERY_LINE", schema="RMADB3")
public class Apo_Ack_Delivery_Line {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY,generator = "select RMADB3.APO_ACK_DELIVERY_LINE_ID.nextval from dual")
private Integer id;
private String deliveryNumber;
}