在编译我的类(它是ActiveAndroid ORM数据库中的表)时,出现此错误:
警告:(33,50)varargs方法的非varargs调用,最后一个参数的参数类型不精确;转换为Object进行varargs调用转换为Object []进行非varargs调用并禁止显示此警告
这是指的方法:
public static ChildMedicine getChildMedicine(Child child, Medicine medicine)
{
return new Select()
.from(ChildMedicine.class)
.where("Child = ? AND Medicine = ?", new Long[]{child.getId(), medicine.getId()})
.executeSingle();
}
我想从我的ActiveAndroid ORM数据库表返回所有ChildMedicine对象,其中Child列等于传入的子参数的Long ID,而Medicine列等于传入的医学参数的Long ID。
我建议用显式数组创建包装wrap vararg参数,如下所示:
public static ChildMedicine getChildMedicine(Child child, Medicine medicine)
{
return new Select()
.from(ChildMedicine.class)
.where("Child = ? AND Medicine = ?", new Object[]{new Long[]{child.getId(), medicine.getId()}})
.executeSingle();
}
但是,这不会导致我的Select()方法无法正常工作,因为我现在在方法的where部分中具有两个Long数组而不是两个Long的Long数组吗?
我有一点疑惑!
任何帮助深表感谢...
谢谢山姆
我不能确定是否不知道该where
方法的签名,但是看来您需要的是:
return new Select()
.from(ChildMedicine.class)
.where("Child = ? AND Medicine = ?", new Object[]{child.getId(), medicine.getId()})
.executeSingle();
这是假设的签名where
就是where (String str, Object... params)
。
另一个可行的选择:
return new Select()
.from(ChildMedicine.class)
.where("Child = ? AND Medicine = ?", child.getId(), medicine.getId())
.executeSingle();
建议使用显式数组创建包装vararg参数
不,那不是你的建议。建议您将anObject
或an传递Object[]
给where
,具体取决于您希望Long[]
将其视为单个参数还是多个参数。传递一个Object[]
包含单个Long[]
元素的毫无意义。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句