import com.alibaba.sample.petstore.dal.dataobject.Sequence;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
public class IbatisSequenceDao extends SqlMapClientDaoSupport implements SequenceDao {
public synchronized int getNextId(String name) {
Sequence sequence = new Sequence(name, -1);
sequence = (Sequence) getSqlMapClientTemplate().queryForObject("getSequence", sequence);
assertNotNull(sequence, "unknown sequence name: {}", name);
Object parameterObject = new Sequence(name, sequence.getNextId() + 1);
getSqlMapClientTemplate().update("updateSequence", parameterObject);
return sequence.getNextId();
}