我在使用ormlite
时遇到问题它给了我重复的ID错误,下面是我的pojo:
public class ParticipantDetailsModel {
@DatabaseField(id = true)
private int id;
@DatabaseField
private String first_name;
@DatabaseField
private String last_name;
}
public class Trainings {
@DatabaseField
private int id;
@DatabaseField
private int participant_id;
@DatabaseField
private int batch_id;
@DatabaseField
private int graduation_program_id;
@DatabaseField(foreign = true, foreignAutoRefresh = true, foreignAutoCreate = true)
private ParticipantDetailsModel participant;
}
目前我需要这个@DatabaseField private int participant_id
来将数据填充到本地数据库。我只需要这个用于加入目的:
@DatabaseField(foreign = true, foreignAutoRefresh = true, foreignAutoCreate = true)
private ParticipantDetailsModel participant;
[Ormlite Problem with duplicate field][1]
这是我的加入查询:
qb1.where().eq("id", item.getId()).and().in("participant_id", parId);
List<Trainings> u = qb1.join(qb2).query();
SELECT `Trainings`.* FROM `Trainings` INNER JOIN `participantdetailsmodel` ON `Trainings`.`participants_id` = `participantdetailsmodel`.`id` WHERE (`Trainings`.`id` = 34 AND `Trainings`.`participant_id` IN () )
ON Trainings
。participants_id
= participantdetailsmodel
。id
这个返回null,因为它在本地数据库上为null。