Insert new data fails
How can I insert new data to a model?
@gnuhel can you be more specific. I don't understand what you mean.
@agrosner I create a model User
@Table(databaseName = PosDatabase.NAME)
public class User extends BaseModel {
@Column(columnType = Column.PRIMARY_KEY)
public int id;
@Column
public String name;
}
and want to insert new data to that model with
new Insert<User>(User.class)
.columns(User$Table.NAME)
.values("Name")
.query();
Is it the right code? It seems not to insert data into User. When I try to output the data
List <User> users = new Select().from(User.class).queryList();
users is empty.
Can you help me? Thanks
I would:
User user = new User();
user.name = "Name";
// determines if exists to update or insert
user.save(false);
// if you know it will not exist at all (or have an ```@Table(insertConflict())``` specified) you can run
user.insert(false);
there are many ways to interact with the DB in this library, which makes it flexible.
@gnuhel actually it looks like you found a nice bug!! good find! its running the wrong method.
This is still open, pending a 1.4.3 release.
What should I do if I want to enter the multiple users at the single time....