
有人知道这是否是真的?
解决方法 您不应该调用createOrUpdate,除非您的对象已经设置了一个ID字段. Ormlite确定它是否存在于数据库中的方式是在其上执行查询.代码:ID ID = extractID(data);// assume we need to create it if there is no ID <<<<<<<<<<<<<<<<<<<<<<<if (ID == null || !IDExists(ID)) { int numRows = create(data); return new CreateOrUpdateStatus(true,false,numRows);} else { int numRows = update(data); return new CreateOrUpdateStatus(false,true,numRows);} 我将扩大javadocs来解释这个更好.他们在那里很弱.抱歉.我已经将它们更新为:
总结This is a convenIEnce method for creating an item in the database if it does not exist. The ID is extracted from the data argument and a query-by-ID is made on the database. If a row in the database with the same ID exists then all of the columns in the database will be updated from the fIElds in the data parameter. If the ID is null (or 0 or some other default value) or doesn’t exist in the database then the object will be created in the database. This also means that your data item must have an ID fIEld defined.
以上是内存溢出为你收集整理的android – createOrUpdate()始终使用ORMLite在数据库中创建一个新条目全部内容,希望文章能够帮你解决android – createOrUpdate()始终使用ORMLite在数据库中创建一个新条目所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)