Playorm java.lang.Integer cannot be cast to java.math.BigInteger -
i tried construct basic ad hoc query example based on a basic ad hoc query example .
but, can't insert integer value. think because of piece of code:
private class getstoragetypeasclass() { switch (getstoragetype()) { case string: return string.class; case integer: return biginteger.class; } }
my 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(); (int = 0; < 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 > 1000 && (i % 10) == 0 ){ session.flush(); mgr.clear(); } } session.flush(); }
there no option return integer.class. so, can't construct integer converter:
exception in thread "main" java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ com.alvazan.orm.impl.meta.data.nosqlproxyimpl.invoke(nosqlproxyimpl.java:96) @ com.alvazan.orm.api.z8spi.meta.dbocolumncommonmeta_$$_javassist_1.converttostorage2(dbocolumncommonmeta_$$_javassist_1.java) @ com.alvazan.orm.api.z8spi.meta.typedrow.addcolumn(typedrow.java:99) @ playorm.playorm.main(playorm.java:62) caused by: java.lang.classcastexception: java.lang.integer cannot cast java.math.biginteger @ com.alvazan.orm.api.z8spi.conv.converters$bigintegerconverter.converttonosqlimpl(converters.java:89) @ com.alvazan.orm.api.z8spi.conv.converters$baseconverter.converttonosql(converters.java:138) @ com.alvazan.orm.api.z8spi.meta.dbocolumnmeta.converttostorage2(dbocolumnmeta.java:167) @ com.alvazan.orm.api.z8spi.meta.dbocolumncommonmeta_$$_javassist_1._d8converttostorage2(dbocolumncommonmeta_$$_javassist_1.java) ... 8 more
typedrow special api , allows biginteger, bigdecimal , string types right now.....these types when stored stored lowest bytes possible int value of 10 stored 1 byte.
out of curiosity, why not use myentity.java class annotated @nosqlentity instead??? in case, using pojo seem more beneficial.
myentity.java can have primitive types, int, double, etc. etc.
we thought using entities use entities make development faster.
later, dean
Comments
Post a Comment