Id生成器
@Component
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
public class FireIdGenerator implements RunMethod {
@Autowired
private PKGenerator pkGenerator;
@Override
public Object run(List<Object> fetchParam) {
return pkGenerator.generate();
}
@Override
public String fetchSelf() {
return "sf";
}
}
Dao
@Configuration
@Repository("dao")
public class XDao extends NutDao {
@Autowired
private FireIdGenerator fireIdGenerator;
private DataSource hikariDataSource;
private FileSqlManager fileSqlManager;
private static final String[] SQLS = {
"user.sql"
};
//虽然调用但是语句还是id 的value 还是 'NULL'
@PostConstruct
public void reg(){
CustomMake.me().register("sf", fireIdGenerator);
}
@Autowired
public void setHikariDataSource(DataSource hikariDataSource) {
this.hikariDataSource = hikariDataSource;
setDataSource(hikariDataSource);
}
@Autowired
public void setFileSqlManager() {
//虽然调用但是语句还是id 的value 还是 'NULL'
CustomMake.me().register("sf", fireIdGenerator);
....
setSqlManager(fileSqlManager);
}
}
Entity
@Table("user_info")
public class UserInfoEntity {
@Id(auto = false)
@Prev(els=@EL("sf('x')"))
private Long id;
@Column("user_name")
private String userName;
//getter & setter
}