当用户单击表单时,将在我的数据库中创建一行。其他一切正常,但未插入外键值。
我创建以下表格:
db.execSQL("create table " + TermDbSchema.CourseTable.NAME + "(" +
"_id integer primary key autoincrement, " +
TermDbSchema.CourseTable.Cols.UUID + ", " +
TermDbSchema.CourseTable.Cols.TITLE + ", " +
TermDbSchema.CourseTable.Cols.START_DATE + ", " +
TermDbSchema.CourseTable.Cols.END_DATE + ", " +
TermDbSchema.CourseTable.Cols.CHOSEN_START_DATE + ", " +
TermDbSchema.CourseTable.Cols.CHOSEN_END_DATE + ", " +
TermDbSchema.CourseTable.Cols.COURSE_STATUS + ", " +
TermDbSchema.CourseTable.Cols.OPTIONAL_NOTE + ", " +
TermDbSchema.CourseTable.Cols.MENTOR_NAME + ", " +
TermDbSchema.CourseTable.Cols.MENTOR_PHONE + ", " +
TermDbSchema.CourseTable.Cols.MENTOR_EMAIL + ", " +
TermDbSchema.CourseTable.Cols.COL_COURSE_TERM_REFERENCE + " INTEGER REFERENCES " + TermDbSchema.TermTable.NAME + "(_id) ON DELETE CASCADE ON UPDATE CASCADE" + //<<<<<<<<<< ADDED
")"
);
db.execSQL("create table " + TermDbSchema.AssessmentTable.NAME + "(" +
"_id integer primary key autoincrement, " +
TermDbSchema.AssessmentTable.Cols.UUID + ", " +
TermDbSchema.AssessmentTable.Cols.TITLE + ", " +
TermDbSchema.AssessmentTable.Cols.ASSESS_TYPE + ", " +
TermDbSchema.AssessmentTable.Cols.DUE_DATE + ", " +
TermDbSchema.AssessmentTable.Cols.GOAL_DATE + ", " +
TermDbSchema.AssessmentTable.Cols.COL_ASSESS_COURSE_REFERENCE + " INTEGER REFERENCES " + TermDbSchema.CourseTable.NAME + "(_id) ON DELETE CASCADE ON UPDATE CASCADE" + //<<<<<<<<<< ADDED
")"
);
这是表格:
public static final class CourseTable {
public static final String NAME = "courses";
public static final class Cols {
public static final String UUID = "uuid";
public static final String TITLE = "title";
public static final String START_DATE = "startdate";
public static final String END_DATE = "enddate";
public static final String CHOSEN_START_DATE = "chosenstartdate";
public static final String CHOSEN_END_DATE = "chosenenddate";
public static final String COURSE_STATUS = "coursestatus";
public static final String OPTIONAL_NOTE = "optionalnote";
public static final String MENTOR_NAME = "mentorname";
public static final String MENTOR_PHONE = "mentorphone";
public static final String MENTOR_EMAIL = "mentoremail";
public static final String COL_COURSE_TERM_REFERENCE = "term_reference";
}
}
public static final class AssessmentTable {
public static final String NAME = "assessments";
public static final class Cols {
public static final String UUID = "uuid";
public static final String TITLE = "title";
public static final String ASSESS_TYPE = "assesstype";
public static final String DUE_DATE = "duedate";
public static final String GOAL_DATE = "goaldate";
public static final String COL_ASSESS_COURSE_REFERENCE = "course_reference";
}
}
这是我制作的游标包装程序:说实话,问题可能出在这里,我不确定游标包装程序的工作方式,我怀疑我在这里做错了什么:
public class AssessmentCursorWrapper extends CursorWrapper {
public AssessmentCursorWrapper(Cursor cursor) {
super(cursor);
}
public Assessment getAssessment() {
String uuidString = getString(getColumnIndex(AssessmentTable.Cols.UUID));
String title = getString(getColumnIndex(AssessmentTable.Cols.TITLE));
String assesstype = getString(getColumnIndex(AssessmentTable.Cols.ASSESS_TYPE));
long duedate = getLong(getColumnIndex(AssessmentTable.Cols.DUE_DATE));
long goaldate = getLong(getColumnIndex(AssessmentTable.Cols.GOAL_DATE));
//this is the foreign key
int course_reference = getInt(getColumnIndex(AssessmentTable.Cols.COL_ASSESS_COURSE_REFERENCE));
Assessment assessment = new Assessment(UUID.fromString(uuidString));
assessment.setTitle(title);
assessment.setAssessType(assesstype);
assessment.setDueDate(new Date(duedate));
assessment.setGoalDate(new Date(goaldate));
assessment.setSelectAssessforCourse(course_reference);
return assessment;
}
}
我进行了一个评估班,让用户单击一个按钮以插入外键值1只是为了测试功能。
public class Assessment {
private int selectAssessforCourse;
private UUID mID;
private String mTitle;
private String mAssessType;
private int selectAssessforCourse;
public int getSelectAssessforCourse() {
return selectAssessforCourse;
}
public void setSelectAssessforCourse(int selectAssessforCourse) {
this.selectAssessforCourse = selectAssessforCourse;
}
}
当用户单击按钮时,我使用setSelectAssessforCourse 测试并查看它是否有效。我只需将数字1插入 进行测试,并且不会插入ID。
mSaveAssessBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mAssessment.setTitle(mTitleField.getText().toString());
mAssessment.setSelectAssessforCourse(1); // I insert 1 to see if the foreign key value of 1 gets inserted
Intent myIntent = new Intent(getActivity(), AssessmentListActivity.class);
startActivity(myIntent);
}
});
答案 0 :(得分:1)
我不认为您需要CursorWrapper,CursorWraper的目的是覆盖游标方法,例如getCount。
我相信您只需要一个游标,例如,您可能只需要类似的东西(以便在每个评估基础上获得所有评估以及课程和学期):->
public Cursor getAllAssessmentsWithCourseAndTermdetails() {
String tables = TermDbSchema.AssessmentTable.NAME +
" JOIN " + TermDbSchema.CourseTable.NAME + " ON " +
TermDbSchema.AssessmentTable.Cols.COL_ASSESS_COURSE_REFERENCE + " = " +
TermDbSchema.CourseTable.NAME + "." + "_id" +
" JOIN " + TermDbSchema.TermTable.NAME + " ON " +
TermDbSchema.CourseTable.Cols.COL_COURSE_TERM_REFERENCE + " = " +
TermDbSchema.TermTable.NAME + "." + "_id";
return this.getWritableDatabase().query(tables,null,null,null,null,null,null);
}
这等同于SQL:-
SELECT * FROM assessments
JOIN courses ON course_reference = courses._id
JOIN terms ON term_reference = terms._id
这是根据您的定义的一个有效示例。该示例中使用的数据库帮助程序类是:-
public class DBHelper extends SQLiteOpenHelper {
public static final String DBNAME = "mydb";
public static final int DBVERSION = 1;
public DBHelper(Context context) {
super(context, DBNAME, null, DBVERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table " + TermDbSchema.TermTable.NAME + "(" +
"_id integer primary key autoincrement, " +
TermDbSchema.TermTable.Cols.UUID + ", " +
TermDbSchema.TermTable.Cols.TITLE + ", " +
TermDbSchema.TermTable.Cols.START_DATE + ", " +
TermDbSchema.TermTable.Cols.END_DATE +
")"
);
db.execSQL("create table " + TermDbSchema.CourseTable.NAME + "(" +
"_id integer primary key autoincrement, " +
TermDbSchema.CourseTable.Cols.UUID + ", " +
TermDbSchema.CourseTable.Cols.TITLE + ", " +
TermDbSchema.CourseTable.Cols.START_DATE + ", " +
TermDbSchema.CourseTable.Cols.END_DATE + ", " +
TermDbSchema.CourseTable.Cols.CHOSEN_START_DATE + ", " +
TermDbSchema.CourseTable.Cols.CHOSEN_END_DATE + ", " +
TermDbSchema.CourseTable.Cols.COURSE_STATUS + ", " +
TermDbSchema.CourseTable.Cols.OPTIONAL_NOTE + ", " +
TermDbSchema.CourseTable.Cols.MENTOR_NAME + ", " +
TermDbSchema.CourseTable.Cols.MENTOR_PHONE + ", " +
TermDbSchema.CourseTable.Cols.MENTOR_EMAIL + ", " +
TermDbSchema.CourseTable.Cols.COL_COURSE_TERM_REFERENCE + " INTEGER REFERENCES " +
TermDbSchema.TermTable.NAME + "(_id) ON DELETE CASCADE ON UPDATE CASCADE" + //<<<<<<<<<< ADDED
")"
);
db.execSQL("create table " + TermDbSchema.AssessmentTable.NAME + "(" +
"_id integer primary key autoincrement, " +
TermDbSchema.AssessmentTable.Cols.UUID + ", " +
TermDbSchema.AssessmentTable.Cols.TITLE + ", " +
TermDbSchema.AssessmentTable.Cols.ASSESS_TYPE + ", " +
TermDbSchema.AssessmentTable.Cols.DUE_DATE + ", " +
TermDbSchema.AssessmentTable.Cols.GOAL_DATE + ", " +
TermDbSchema.AssessmentTable.Cols.COL_ASSESS_COURSE_REFERENCE + " INTEGER REFERENCES " + TermDbSchema.CourseTable.NAME + "(_id) ON DELETE CASCADE ON UPDATE CASCADE" + //<<<<<<<<<< ADDED
")"
);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
@Override
public void onConfigure(SQLiteDatabase db) {
super.onConfigure(db);
db.setForeignKeyConstraintsEnabled(true);
}
public long addTerm(String title, String start_date, String end_date) {
ContentValues cv = new ContentValues();
cv.put(TermDbSchema.TermTable.Cols.TITLE,title);
cv.put(TermDbSchema.TermTable.Cols.START_DATE,start_date);
cv.put(TermDbSchema.TermTable.Cols.END_DATE,end_date);
return this.getWritableDatabase().insert(TermDbSchema.TermTable.NAME,null,cv);
}
public long addCourse(
String title,
String start_date,
String end_date,
String chosen_start_date,
String chosen_end_date,
String status, String note,
String mentor_name,
String mentor_phone,
String mentor_email,
long course_reference) {
ContentValues cv = new ContentValues();
cv.put(TermDbSchema.CourseTable.Cols.TITLE,title);
cv.put(TermDbSchema.CourseTable.Cols.START_DATE,start_date);
cv.put(TermDbSchema.CourseTable.Cols.END_DATE,end_date);
cv.put(TermDbSchema.CourseTable.Cols.CHOSEN_START_DATE,chosen_start_date);
cv.put(TermDbSchema.CourseTable.Cols.CHOSEN_END_DATE,chosen_end_date);
cv.put(TermDbSchema.CourseTable.Cols.COURSE_STATUS,status);
cv.put(TermDbSchema.CourseTable.Cols.OPTIONAL_NOTE,note);
cv.put(TermDbSchema.CourseTable.Cols.MENTOR_NAME,mentor_name);
cv.put(TermDbSchema.CourseTable.Cols.MENTOR_PHONE,mentor_phone);
cv.put(TermDbSchema.CourseTable.Cols.MENTOR_EMAIL,mentor_email);
cv.put(TermDbSchema.CourseTable.Cols.COL_COURSE_TERM_REFERENCE,course_reference);
return this.getWritableDatabase().insert(TermDbSchema.CourseTable.NAME,null,cv);
}
public long addAssessment(
String title,
String assessType,
String duedate,
String goaldate,
long course_reference) {
ContentValues cv = new ContentValues();
cv.put(TermDbSchema.AssessmentTable.Cols.TITLE, title);
cv.put(TermDbSchema.AssessmentTable.Cols.ASSESS_TYPE,assessType);
cv.put(TermDbSchema.AssessmentTable.Cols.DUE_DATE,duedate);
cv.put(TermDbSchema.AssessmentTable.Cols.GOAL_DATE,goaldate);
cv.put(TermDbSchema.AssessmentTable.Cols.COL_ASSESS_COURSE_REFERENCE,course_reference);
return this.getWritableDatabase().insert(TermDbSchema.AssessmentTable.NAME,null,cv);
}
public Cursor getAllCoursesWithTermDetails() {
String tables = TermDbSchema.CourseTable.NAME +
" JOIN " + TermDbSchema.TermTable.NAME + " ON " +
TermDbSchema.CourseTable.Cols.COL_COURSE_TERM_REFERENCE + " = " +
TermDbSchema.TermTable.NAME + "." + "_id";
return this.getWritableDatabase().query(tables,null,null,null,null,null,null);
}
public Cursor getAllAssessmentsWithCourseAndTermdetails() {
String tables = TermDbSchema.AssessmentTable.NAME +
" JOIN " + TermDbSchema.CourseTable.NAME + " ON " +
TermDbSchema.AssessmentTable.Cols.COL_ASSESS_COURSE_REFERENCE + " = " +
TermDbSchema.CourseTable.NAME + "." + "_id" +
" JOIN " + TermDbSchema.TermTable.NAME + " ON " +
TermDbSchema.CourseTable.Cols.COL_COURSE_TERM_REFERENCE + " = " +
TermDbSchema.TermTable.NAME + "." + "_id";
return this.getWritableDatabase().query(tables,null,null,null,null,null,null);
}
}
要测试以上内容,请使用:-
public class MainActivity extends AppCompatActivity {
DBHelper mDBHlpr;
ArrayList<Long> terms = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDBHlpr = new DBHelper(this);
addSometestingData();
Cursor csr = mDBHlpr.getAllCoursesWithTermDetails();
DatabaseUtils.dumpCursor(csr);
csr = mDBHlpr.getAllAssessmentsWithCourseAndTermdetails();
DatabaseUtils.dumpCursor(csr);
}
private void addSometestingData() {
if (DatabaseUtils.queryNumEntries(mDBHlpr.getWritableDatabase(), TermDbSchema.TermTable.NAME) < 1) {
addSomeTerms();
addSomeCourses();
addSomeAssessments();
}
}
private void addSomeTerms() {
terms.add(mDBHlpr.addTerm("TERM001","2019-01-01","2019-0331"));
terms.add(mDBHlpr.addTerm("TERM002","2019-04-01","2019-06-30"));
terms.add(mDBHlpr.addTerm("TERM003","2019-07-01","2019-09-30"));
terms.add(mDBHlpr.addTerm("TERM004","2019-10-01","2019-12-31"));
}
private void addSomeCourses() {
mDBHlpr.addCourse(
"Math01",
"2019-01-01","2019-03-14","2019-01-03","2019-03-07",
"OK","blah",
"Fred","0000000000","fred@email.com",
terms.get(0));
mDBHlpr.addCourse(
"Math02",
"2019-04-01","2019-06-14","2019-04-03","2019-06-07",
"OK","blah",
"Fred","0000000000","fred@email.com",
terms.get(1));
mDBHlpr.addCourse(
"Math03",
"2019-07-01","2019-09-14","2019-07-03","2019-09-07",
"OK","blah",
"Fred","0000000000","fred@email.com",
terms.get(2));
mDBHlpr.addCourse(
"Math01",
"2019-10-01","2019-12-14","2019-10-03","2019-12-07",
"OK","blah",
"Fred","0000000000","fred@email.com",
terms.get(3));
}
private void addSomeAssessments() {
mDBHlpr.addAssessment("MATH02-A01","?","2019-01-31","2019-01-24",1);
mDBHlpr.addAssessment("MATH01-A02","?","2019-02-28","2019-02-21",1);
mDBHlpr.addAssessment("MATH01-A03","?","2019-03-31","2019-03-24",1);
mDBHlpr.addAssessment("MATH02-A01","?","2019-04-30","2019-04-23",2);
// and so on
}
}
2019-05-13 11:22:06.344 I/System.out: >>>>> Dumping cursor android.database.sqlite.SQLiteCursor@76cd9ae
2019-05-13 11:22:06.345 I/System.out: 0 {
2019-05-13 11:22:06.345 I/System.out: _id=1
2019-05-13 11:22:06.345 I/System.out: uuid=null
2019-05-13 11:22:06.345 I/System.out: title=Math01
2019-05-13 11:22:06.345 I/System.out: startdate=2019-01-01
2019-05-13 11:22:06.345 I/System.out: enddate=2019-03-14
2019-05-13 11:22:06.345 I/System.out: chosenstartdate=2019-01-03
2019-05-13 11:22:06.346 I/System.out: chosenenddate=2019-03-07
2019-05-13 11:22:06.346 I/System.out: coursestatus=OK
2019-05-13 11:22:06.346 I/System.out: optionalnote=blah
2019-05-13 11:22:06.346 I/System.out: mentorname=Fred
2019-05-13 11:22:06.346 I/System.out: mentorphone=0000000000
2019-05-13 11:22:06.346 I/System.out: mentoremail=fred@email.com
2019-05-13 11:22:06.346 I/System.out: term_reference=1
2019-05-13 11:22:06.346 I/System.out: _id=1
2019-05-13 11:22:06.346 I/System.out: uuid=null
2019-05-13 11:22:06.347 I/System.out: title=TERM001
2019-05-13 11:22:06.347 I/System.out: startdate=2019-01-01
2019-05-13 11:22:06.347 I/System.out: enddate=2019-0331
2019-05-13 11:22:06.347 I/System.out: }
2019-05-13 11:22:06.347 I/System.out: 1 {
2019-05-13 11:22:06.347 I/System.out: _id=2
2019-05-13 11:22:06.347 I/System.out: uuid=null
2019-05-13 11:22:06.347 I/System.out: title=Math02
2019-05-13 11:22:06.347 I/System.out: startdate=2019-04-01
2019-05-13 11:22:06.347 I/System.out: enddate=2019-06-14
2019-05-13 11:22:06.347 I/System.out: chosenstartdate=2019-04-03
2019-05-13 11:22:06.347 I/System.out: chosenenddate=2019-06-07
2019-05-13 11:22:06.347 I/System.out: coursestatus=OK
2019-05-13 11:22:06.347 I/System.out: optionalnote=blah
2019-05-13 11:22:06.348 I/System.out: mentorname=Fred
2019-05-13 11:22:06.348 I/System.out: mentorphone=0000000000
2019-05-13 11:22:06.348 I/System.out: mentoremail=fred@email.com
2019-05-13 11:22:06.348 I/System.out: term_reference=2
2019-05-13 11:22:06.348 I/System.out: _id=2
2019-05-13 11:22:06.348 I/System.out: uuid=null
2019-05-13 11:22:06.348 I/System.out: title=TERM002
2019-05-13 11:22:06.348 I/System.out: startdate=2019-04-01
2019-05-13 11:22:06.349 I/System.out: enddate=2019-06-30
2019-05-13 11:22:06.349 I/System.out: }
2019-05-13 11:22:06.349 I/System.out: 2 {
2019-05-13 11:22:06.349 I/System.out: _id=3
2019-05-13 11:22:06.349 I/System.out: uuid=null
2019-05-13 11:22:06.349 I/System.out: title=Math03
2019-05-13 11:22:06.349 I/System.out: startdate=2019-07-01
2019-05-13 11:22:06.349 I/System.out: enddate=2019-09-14
2019-05-13 11:22:06.349 I/System.out: chosenstartdate=2019-07-03
2019-05-13 11:22:06.350 I/System.out: chosenenddate=2019-09-07
2019-05-13 11:22:06.350 I/System.out: coursestatus=OK
2019-05-13 11:22:06.350 I/System.out: optionalnote=blah
2019-05-13 11:22:06.350 I/System.out: mentorname=Fred
2019-05-13 11:22:06.350 I/System.out: mentorphone=0000000000
2019-05-13 11:22:06.350 I/System.out: mentoremail=fred@email.com
2019-05-13 11:22:06.350 I/System.out: term_reference=3
2019-05-13 11:22:06.350 I/System.out: _id=3
2019-05-13 11:22:06.350 I/System.out: uuid=null
2019-05-13 11:22:06.350 I/System.out: title=TERM003
2019-05-13 11:22:06.350 I/System.out: startdate=2019-07-01
2019-05-13 11:22:06.350 I/System.out: enddate=2019-09-30
2019-05-13 11:22:06.350 I/System.out: }
2019-05-13 11:22:06.350 I/System.out: 3 {
2019-05-13 11:22:06.350 I/System.out: _id=4
2019-05-13 11:22:06.350 I/System.out: uuid=null
2019-05-13 11:22:06.350 I/System.out: title=Math01
2019-05-13 11:22:06.350 I/System.out: startdate=2019-10-01
2019-05-13 11:22:06.350 I/System.out: enddate=2019-12-14
2019-05-13 11:22:06.351 I/System.out: chosenstartdate=2019-10-03
2019-05-13 11:22:06.351 I/System.out: chosenenddate=2019-12-07
2019-05-13 11:22:06.351 I/System.out: coursestatus=OK
2019-05-13 11:22:06.351 I/System.out: optionalnote=blah
2019-05-13 11:22:06.351 I/System.out: mentorname=Fred
2019-05-13 11:22:06.351 I/System.out: mentorphone=0000000000
2019-05-13 11:22:06.351 I/System.out: mentoremail=fred@email.com
2019-05-13 11:22:06.351 I/System.out: term_reference=4
2019-05-13 11:22:06.351 I/System.out: _id=4
2019-05-13 11:22:06.351 I/System.out: uuid=null
2019-05-13 11:22:06.351 I/System.out: title=TERM004
2019-05-13 11:22:06.351 I/System.out: startdate=2019-10-01
2019-05-13 11:22:06.351 I/System.out: enddate=2019-12-31
2019-05-13 11:22:06.351 I/System.out: }
2019-05-13 11:22:06.351 I/System.out: <<<<<
2019-05-13 11:22:06.353 I/System.out: course_reference=1
2019-05-13 11:22:06.355 I/System.out: course_reference=1
2019-05-13 11:22:06.356 I/System.out: course_reference=1
>> 2019-05-13 11:22:06.358 I/System.out: course_reference=2
:-
2019-05-13 11:22:06.352 I/System.out: >>>>> Dumping cursor android.database.sqlite.SQLiteCursor@e3fe34f
2019-05-13 11:22:06.353 I/System.out: 0 {
2019-05-13 11:22:06.353 I/System.out: _id=1
2019-05-13 11:22:06.353 I/System.out: uuid=null
2019-05-13 11:22:06.353 I/System.out: title=MATH02-A01
2019-05-13 11:22:06.353 I/System.out: assesstype=?
2019-05-13 11:22:06.353 I/System.out: duedate=2019-01-31
2019-05-13 11:22:06.353 I/System.out: goaldate=2019-01-24
2019-05-13 11:22:06.353 I/System.out: course_reference=1
2019-05-13 11:22:06.353 I/System.out: _id=1
2019-05-13 11:22:06.353 I/System.out: uuid=null
2019-05-13 11:22:06.353 I/System.out: title=Math01
2019-05-13 11:22:06.353 I/System.out: startdate=2019-01-01
2019-05-13 11:22:06.353 I/System.out: enddate=2019-03-14
2019-05-13 11:22:06.353 I/System.out: chosenstartdate=2019-01-03
2019-05-13 11:22:06.354 I/System.out: chosenenddate=2019-03-07
2019-05-13 11:22:06.354 I/System.out: coursestatus=OK
2019-05-13 11:22:06.354 I/System.out: optionalnote=blah
2019-05-13 11:22:06.354 I/System.out: mentorname=Fred
2019-05-13 11:22:06.354 I/System.out: mentorphone=0000000000
2019-05-13 11:22:06.354 I/System.out: mentoremail=fred@email.com
2019-05-13 11:22:06.354 I/System.out: term_reference=1
2019-05-13 11:22:06.354 I/System.out: _id=1
2019-05-13 11:22:06.354 I/System.out: uuid=null
2019-05-13 11:22:06.354 I/System.out: title=TERM001
2019-05-13 11:22:06.354 I/System.out: startdate=2019-01-01
2019-05-13 11:22:06.354 I/System.out: enddate=2019-0331
2019-05-13 11:22:06.354 I/System.out: }
2019-05-13 11:22:06.354 I/System.out: 1 {
2019-05-13 11:22:06.354 I/System.out: _id=2
2019-05-13 11:22:06.354 I/System.out: uuid=null
2019-05-13 11:22:06.354 I/System.out: title=MATH01-A02
2019-05-13 11:22:06.354 I/System.out: assesstype=?
2019-05-13 11:22:06.354 I/System.out: duedate=2019-02-28
2019-05-13 11:22:06.354 I/System.out: goaldate=2019-02-21
2019-05-13 11:22:06.355 I/System.out: course_reference=1
2019-05-13 11:22:06.355 I/System.out: _id=1
2019-05-13 11:22:06.355 I/System.out: uuid=null
2019-05-13 11:22:06.355 I/System.out: title=Math01
2019-05-13 11:22:06.355 I/System.out: startdate=2019-01-01
2019-05-13 11:22:06.355 I/System.out: enddate=2019-03-14
2019-05-13 11:22:06.355 I/System.out: chosenstartdate=2019-01-03
2019-05-13 11:22:06.355 I/System.out: chosenenddate=2019-03-07
2019-05-13 11:22:06.355 I/System.out: coursestatus=OK
2019-05-13 11:22:06.355 I/System.out: optionalnote=blah
2019-05-13 11:22:06.355 I/System.out: mentorname=Fred
2019-05-13 11:22:06.355 I/System.out: mentorphone=0000000000
2019-05-13 11:22:06.355 I/System.out: mentoremail=fred@email.com
2019-05-13 11:22:06.355 I/System.out: term_reference=1
2019-05-13 11:22:06.355 I/System.out: _id=1
2019-05-13 11:22:06.355 I/System.out: uuid=null
2019-05-13 11:22:06.355 I/System.out: title=TERM001
2019-05-13 11:22:06.355 I/System.out: startdate=2019-01-01
2019-05-13 11:22:06.355 I/System.out: enddate=2019-0331
2019-05-13 11:22:06.355 I/System.out: }
2019-05-13 11:22:06.355 I/System.out: 2 {
2019-05-13 11:22:06.356 I/System.out: _id=3
2019-05-13 11:22:06.356 I/System.out: uuid=null
2019-05-13 11:22:06.356 I/System.out: title=MATH01-A03
2019-05-13 11:22:06.356 I/System.out: assesstype=?
2019-05-13 11:22:06.356 I/System.out: duedate=2019-03-31
2019-05-13 11:22:06.356 I/System.out: goaldate=2019-03-24
2019-05-13 11:22:06.356 I/System.out: course_reference=1
2019-05-13 11:22:06.356 I/System.out: _id=1
2019-05-13 11:22:06.356 I/System.out: uuid=null
2019-05-13 11:22:06.356 I/System.out: title=Math01
2019-05-13 11:22:06.356 I/System.out: startdate=2019-01-01
2019-05-13 11:22:06.356 I/System.out: enddate=2019-03-14
2019-05-13 11:22:06.356 I/System.out: chosenstartdate=2019-01-03
2019-05-13 11:22:06.356 I/System.out: chosenenddate=2019-03-07
2019-05-13 11:22:06.357 I/System.out: coursestatus=OK
2019-05-13 11:22:06.357 I/System.out: optionalnote=blah
2019-05-13 11:22:06.357 I/System.out: mentorname=Fred
2019-05-13 11:22:06.357 I/System.out: mentorphone=0000000000
2019-05-13 11:22:06.357 I/System.out: mentoremail=fred@email.com
2019-05-13 11:22:06.357 I/System.out: term_reference=1
2019-05-13 11:22:06.357 I/System.out: _id=1
2019-05-13 11:22:06.357 I/System.out: uuid=null
2019-05-13 11:22:06.357 I/System.out: title=TERM001
2019-05-13 11:22:06.357 I/System.out: startdate=2019-01-01
2019-05-13 11:22:06.357 I/System.out: enddate=2019-0331
2019-05-13 11:22:06.357 I/System.out: }
2019-05-13 11:22:06.358 I/System.out: 3 {
2019-05-13 11:22:06.358 I/System.out: _id=4
2019-05-13 11:22:06.358 I/System.out: uuid=null
2019-05-13 11:22:06.358 I/System.out: title=MATH02-A01
2019-05-13 11:22:06.358 I/System.out: assesstype=?
2019-05-13 11:22:06.358 I/System.out: duedate=2019-04-30
2019-05-13 11:22:06.358 I/System.out: goaldate=2019-04-23
2019-05-13 11:22:06.358 I/System.out: course_reference=2
2019-05-13 11:22:06.358 I/System.out: _id=2
2019-05-13 11:22:06.358 I/System.out: uuid=null
2019-05-13 11:22:06.358 I/System.out: title=Math02
2019-05-13 11:22:06.358 I/System.out: startdate=2019-04-01
2019-05-13 11:22:06.358 I/System.out: enddate=2019-06-14
2019-05-13 11:22:06.358 I/System.out: chosenstartdate=2019-04-03
2019-05-13 11:22:06.358 I/System.out: chosenenddate=2019-06-07
2019-05-13 11:22:06.358 I/System.out: coursestatus=OK
2019-05-13 11:22:06.358 I/System.out: optionalnote=blah
2019-05-13 11:22:06.359 I/System.out: mentorname=Fred
2019-05-13 11:22:06.359 I/System.out: mentorphone=0000000000
2019-05-13 11:22:06.359 I/System.out: mentoremail=fred@email.com
2019-05-13 11:22:06.359 I/System.out: term_reference=2
2019-05-13 11:22:06.359 I/System.out: _id=2
2019-05-13 11:22:06.359 I/System.out: uuid=null
2019-05-13 11:22:06.359 I/System.out: title=TERM002
2019-05-13 11:22:06.359 I/System.out: startdate=2019-04-01
2019-05-13 11:22:06.359 I/System.out: enddate=2019-06-30
2019-05-13 11:22:06.359 I/System.out: }
2019-05-13 11:22:06.359 I/System.out: <<<<<
P.S。我没有麻烦设置UUID的