litesuits / android-lite-orm

LiteOrm is a fast, small, powerful ORM framework for Android. LiteOrm makes you do CRUD operarions on SQLite database with a sigle line of code efficiently.
http://litesuits.com?form=gorm
Apache License 2.0
1.49k stars 362 forks source link

无法插入级联数据 #26

Open szhupeng opened 8 years ago

szhupeng commented 8 years ago

@Table("tb_user") public class UserModel extends BaseModel { private static final long serialVersionUID = 1L;

public static final String COL_MOBILE = "mobile";

@NotNull
@Column(COL_MOBILE)
private String mobile;

@Mapping(Relation.OneToMany) private ArrayList roles; }

@Table("tb_role") public class RoleModel extends BaseModel {

@Unique
@NotNull
private int roleId;

private String role;

} 用 public void insert(T t) { getLiteOrm().cascade().insert(t, ConflictAlgorithm.Abort); } 插入数据userMode,UserModel中其他字段都可以插入,唯独roles是空

litesuits commented 8 years ago
  1. 注意warnning级别的日志,会说明失败的原因。
  2. 注意到两者都是集成自BaseModel,注意下两者是否都有主键id字段
  3. roleId是Unique的,检测是否为其赋了唯一值,如果没有,那么会触发唯一性冲突,必然失败

~如果解决,请关闭issue

szhupeng commented 8 years ago

我以前用的是1.7,今天打算换成1.9之后级联插入就失败了,重新换过来又好了

litesuits commented 8 years ago

麻烦贴一下异常栈信息