package vk.java.api.persistence.dao;

import org.hibernate.Query;
import org.hibernate.type.StandardBasicTypes;
import vk.java.api.persistence.sharding.HibernateShardingDaoSupport;
import vk.java.api.persistence.sharding.ShardingContextHolder;

/**
 * @author Skurishin Vladislav
 * @since 24.03.15
 */
public class AbstractDaoSupport extends HibernateShardingDaoSupport
{
    Long getNext(String sequence)
    {
        ShardingContextHolder.set(getBindingName(), 0L);

        String SEQ_SQL = String.format("SELECT %s.nextval AS num FROM person", sequence);

        Query query = getSessionFactory().getCurrentSession().createSQLQuery(SEQ_SQL)
                .addScalar("num", StandardBasicTypes.LONG);

        return (Long) query.uniqueResult();
    }
}

@@ -460,24 +460,96 @@
 me(), 0L);%0A%0A
+        // %D0%92%D0%B7%D1%8F%D1%82%D1%8C %D0%BF%D0%B5%D1%80%D0%B2%D0%BE%D0%B5 AtomicInteger %D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%B8%D0%B5 %D0%B2 %D0%B1%D0%B0%D0%B7%D0%B5 %D0%B8 %D1%85%D1%80%D0%B0%D0%BD%D0%B8%D1%82%D1%8C %D0%B2 %D0%BA%D1%8D%D1%88%D0%B5.%0A
         Stri

add jdoc.