سؤال

Can a uniqueCombo identify a field when one or more fields of this combo are null?

class Entity {
    @DatabaseField(columnName = "fieldA", canBeNull = true, uniqueCombo = true)
    private String fieldA;

    @DatabaseField(columnName = "fieldB", canBeNull = true, uniqueCombo = true)
    private String fieldB;
}

If there was a record in table Entity where fieldA is 'John'and fieldB is null, would querying this result in 1 record?

dao.queryForFirst(
    dao.queryBuilder().
        where().
            eq("fieldA", "John").
        and().
            eq("fieldB", null).
        prepare());
هل كانت مفيدة؟

المحلول

Ok, this seems to be tied to the DB engine. When using MySQL, it is handeled by the rules the selected MySQL engine dicates.

This answer was very helpful

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top