title: Playorm java.lang.Integer cannot be cast to java.math.BigInteger
body: <p>I tried to construct a basic ad hoc query example based on <a href="http://buffalosw.com/wiki/A-basic-ad-hoc-query-example" rel="nofollow">A basic ad hoc query example
  </a>.</p>
  
  <p>But, I can't insert a Integer value. I think it is because of this piece of code:</p>
  
  <pre><code>private Class getStorageTypeAsClass() {
      switch (getStorageType())
      {
          case STRING:
              return String.class;
          case INTEGER:
              return BigInteger.class;
      }
  }
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>package playorm;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.UUID;
  
  import com.alvazan.orm.api.base.Bootstrap;
  import com.alvazan.orm.api.base.DbTypeEnum;
  import com.alvazan.orm.api.base.NoSqlEntityManager;
  import com.alvazan.orm.api.base.NoSqlEntityManagerFactory;
  import com.alvazan.orm.api.z3api.NoSqlTypedSession;
  import com.alvazan.orm.api.z8spi.KeyValue;
  import com.alvazan.orm.api.z8spi.meta.DboColumnCommonMeta;
  import com.alvazan.orm.api.z8spi.meta.DboColumnIdMeta;
  import com.alvazan.orm.api.z8spi.meta.DboDatabaseMeta;
  import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
  import com.alvazan.orm.api.z8spi.meta.TypedColumn;
  import com.alvazan.orm.api.z8spi.meta.TypedRow;
  
  public class PlayOrm {
      private static NoSqlEntityManager mgr;
  
      @SuppressWarnings({ "unchecked", "rawtypes" })
      public static void main(String[] args) {
  
          Map properties = new HashMap();
          properties.put(Bootstrap.AUTO_CREATE_KEY, "create");
  
          String clusterName = "Test Cluster";
          String seeds = "localhost:9160";
          String keyspace = "nosql";
  
          Bootstrap.createAndAddBestCassandraConfiguration(properties, clusterName, keyspace, seeds);
          NoSqlEntityManagerFactory factory = Bootstrap.create(DbTypeEnum.CASSANDRA, properties,null,null);
          mgr = factory.createEntityManager();
          DboDatabaseMeta metaDb = mgr.find(DboDatabaseMeta.class,
                  DboDatabaseMeta.META_DB_ROWKEY);
          DboTableMeta meta = new DboTableMeta();
          meta.setup(null, "MyEntity", false);
          metaDb.addMetaClassDbo(meta);
  
          DboColumnIdMeta idMeta = new DboColumnIdMeta();
          idMeta.setup(meta, "idField", String.class, true);
          mgr.put(idMeta);
  
          DboColumnCommonMeta fieldDbo = new DboColumnCommonMeta();
          fieldDbo.setup(meta, "firstname", String.class, true, false);
          mgr.put(fieldDbo);
          DboColumnCommonMeta fieldDbo2 = new DboColumnCommonMeta();
          fieldDbo2.setup(meta, "lastname", Integer.class, true, false);
          mgr.put(fieldDbo2);
  
          mgr.put(meta);
          mgr.flush();
  
          NoSqlTypedSession session = mgr.getTypedSession();
          for (int i = 0; i &lt; 10000; i++) {
              TypedRow typedRow = session.createTypedRow("MyEntity");
              typedRow.addColumn("firstname", "harry");
                          //**THE PROBLEM**
              typedRow.addColumn("lastname", new Integer(i));
              typedRow.setRowKey(UUID.randomUUID().toString());
  
              session.put("MyEntity", typedRow);
  
              if(i &gt; 1000 &amp;&amp; (i % 10) == 0 ){
                  session.flush();
                  mgr.clear();
              }
  
          }
          session.flush();
  
  }
  </code></pre>
  
  <p>There is no option to return Integer.class. So, it can't construct a Integer converter:</p>
  
  <pre><code>Exception in thread "main" java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.alvazan.orm.impl.meta.data.NoSqlProxyImpl.invoke(NoSqlProxyImpl.java:96)
      at com.alvazan.orm.api.z8spi.meta.DboColumnCommonMeta_$$_javassist_1.convertToStorage2(DboColumnCommonMeta_$$_javassist_1.java)
      at com.alvazan.orm.api.z8spi.meta.TypedRow.addColumn(TypedRow.java:99)
      at playorm.PlayOrm.main(PlayOrm.java:62)
  Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.math.BigInteger
      at com.alvazan.orm.api.z8spi.conv.Converters$BigIntegerConverter.convertToNoSqlImpl(Converters.java:89)
      at com.alvazan.orm.api.z8spi.conv.Converters$BaseConverter.convertToNoSql(Converters.java:138)
      at com.alvazan.orm.api.z8spi.meta.DboColumnMeta.convertToStorage2(DboColumnMeta.java:167)
      at com.alvazan.orm.api.z8spi.meta.DboColumnCommonMeta_$$_javassist_1._d8convertToStorage2(DboColumnCommonMeta_$$_javassist_1.java)
      ... 8 more
  </code></pre>