File tree Expand file tree Collapse file tree
library/src/com/lidroid/xutils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -580,7 +580,7 @@ public static class DaoConfig {
580580 private String dbDir ;
581581
582582 public DaoConfig (Context context ) {
583- this .context = context ;
583+ this .context = context . getApplicationContext () ;
584584 }
585585
586586 public Context getContext () {
Original file line number Diff line number Diff line change @@ -107,9 +107,15 @@ public Object getColumnValue(Object entity) {
107107 Column column = TableUtils .getColumnOrId (foreignEntityType , foreignColumnName );
108108 columnValue = column .getColumnValue (foreignEntities .get (0 ));
109109
110+ // 仅自动关联外键
110111 Table table = this .getTable ();
111- if (table != null && columnValue == null && column instanceof Id ) {
112- table .db .saveOrUpdateAll (foreignEntities );
112+ if (table != null && column instanceof Id ) {
113+ for (Object foreignObj : foreignEntities ) {
114+ Object idValue = column .getColumnValue (foreignObj );
115+ if (idValue == null ) {
116+ table .db .saveOrUpdate (foreignObj );
117+ }
118+ }
113119 }
114120
115121 columnValue = column .getColumnValue (foreignEntities .get (0 ));
You can’t perform that action at this time.
0 commit comments