I have this object:
public class Set {
@DatabaseField(columnName = "setID", generatedId = true)
private int setID;
@DatabaseField(columnName = "setName")
private String setName;
}
If I make an object like this:
Set newSet = new Set("name");
setDao.create(newSet);
And then if i make this:
int id = newSet.getID();
Will I get the set id or should I get the whole object from the database with
setDao.queryForEq("setName", "name");
So the ORMLite documentation is pretty extensive. If you look up generated-id in the docs you’d see the following statement:
So after you call
setDao.create(newSet), thenewSetobject’ssetIDfield will be changed with the id from the database.Also, calling a field
setIDis a very bad pattern. I’d recommend just useid.