So I have quite a complex SQL Structure, but for a small example:
@Table(name = "Events", id = "_id")
public class DBEvent extends Model implements Event {
@Column(name = "Id", unique = true)
protected Long id;
@Column(name = "name")
protected String name;
@Column(name = "start_time")
protected Date startTime;
@Column(name = "end_time")
protected Date endTime;
@Column(name = "version")
protected int version = -1;
@Column(name = "visited")
protected boolean visited = false;
@Column(name = "venue")
private DBVenue venue;
}
@Table(name = "Surveys", id = "_id")
public class DBSurvey extends Model implements Versionable, Dateable, Survey {
@Column(name = "Id", unique = true)
protected Long id;
@Column(name = "name")
protected String name;
@Column(name = "start_time")
protected Date startTime;
@Column(name = "end_time")
protected Date endTime;
@Column(name = "version")
protected int version = -1;
@Column(name = "done")
protected boolean done = false;
@Column(name = "scheduled")
protected boolean scheduled = false;
}
The following Query always returns empty. And it's only with this model, my other model works fine.
List<DBSurvey> surveys = new Select().from(DBSurvey.class).where("event=?", id).execute();
However, if I do:
List<DBSurvey> surveys = new ArrayList<>();
for (DBSurvey survey : EntityUtil.listAll(DBSurvey.class)) {
if (survey.getEvent().getEntityId() == this.getEntityId()) {
surveys.add(survey);
}
}
return surveys;
I get the correct objects. Any help is appreciated. I realize that event is a keyword in regular sql, however it is not in SQLLite and I have changed the name to event_id to no avail.
Aucun commentaire:
Enregistrer un commentaire