Created
January 12, 2023 21:33
-
-
Save ericntd/6599c745c71b46c04395187c16e14cf2 to your computer and use it in GitHub Desktop.
Room @relation auto-generated code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public Flow<List<QuestionWithRelations>> readMcqAnswers1() { | |
final String _sql = "SELECT * FROM question"; | |
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, 0); | |
return CoroutinesRoom.createFlow(__db, false, new String[]{"option","answer","question"}, new Callable<List<QuestionWithRelations>>() { | |
@Override | |
public List<QuestionWithRelations> call() throws Exception { | |
final Cursor _cursor = DBUtil.query(__db, _statement, true, null); | |
try { | |
final int _cursorIndexOfId = CursorUtil.getColumnIndexOrThrow(_cursor, "question_id"); | |
final int _cursorIndexOfText = CursorUtil.getColumnIndexOrThrow(_cursor, "question_text"); | |
final ArrayMap<String, ArrayList<OptionEntity>> _collectionOptions = new ArrayMap<String, ArrayList<OptionEntity>>(); | |
final ArrayMap<String, ArrayList<AnswerEntity>> _collectionAnswers = new ArrayMap<String, ArrayList<AnswerEntity>>(); | |
while (_cursor.moveToNext()) { | |
final String _tmpKey = _cursor.getString(_cursorIndexOfId); | |
ArrayList<OptionEntity> _tmpOptionsCollection = _collectionOptions.get(_tmpKey); | |
if (_tmpOptionsCollection == null) { | |
_tmpOptionsCollection = new ArrayList<OptionEntity>(); | |
_collectionOptions.put(_tmpKey, _tmpOptionsCollection); | |
} | |
final String _tmpKey_1 = _cursor.getString(_cursorIndexOfId); | |
ArrayList<AnswerEntity> _tmpAnswersCollection = _collectionAnswers.get(_tmpKey_1); | |
if (_tmpAnswersCollection == null) { | |
_tmpAnswersCollection = new ArrayList<AnswerEntity>(); | |
_collectionAnswers.put(_tmpKey_1, _tmpAnswersCollection); | |
} | |
} | |
_cursor.moveToPosition(-1); | |
__fetchRelationshipoptionAsappEricnMyqaOptionEntity(_collectionOptions); | |
__fetchRelationshipanswerAsappEricnMyqaAnswerEntity(_collectionAnswers); | |
final List<QuestionWithRelations> _result = new ArrayList<QuestionWithRelations>(_cursor.getCount()); | |
while(_cursor.moveToNext()) { | |
final QuestionWithRelations _item; | |
final QuestionEntity _tmpQuestion; | |
if (! (_cursor.isNull(_cursorIndexOfId) && _cursor.isNull(_cursorIndexOfText))) { | |
final String _tmpId; | |
if (_cursor.isNull(_cursorIndexOfId)) { | |
_tmpId = null; | |
} else { | |
_tmpId = _cursor.getString(_cursorIndexOfId); | |
} | |
final String _tmpText; | |
if (_cursor.isNull(_cursorIndexOfText)) { | |
_tmpText = null; | |
} else { | |
_tmpText = _cursor.getString(_cursorIndexOfText); | |
} | |
_tmpQuestion = new QuestionEntity(_tmpId,_tmpText); | |
} else { | |
_tmpQuestion = null; | |
} | |
ArrayList<OptionEntity> _tmpOptionsCollection_1 = null; | |
final String _tmpKey_2 = _cursor.getString(_cursorIndexOfId); | |
_tmpOptionsCollection_1 = _collectionOptions.get(_tmpKey_2); | |
if (_tmpOptionsCollection_1 == null) { | |
_tmpOptionsCollection_1 = new ArrayList<OptionEntity>(); | |
} | |
ArrayList<AnswerEntity> _tmpAnswersCollection_1 = null; | |
final String _tmpKey_3 = _cursor.getString(_cursorIndexOfId); | |
_tmpAnswersCollection_1 = _collectionAnswers.get(_tmpKey_3); | |
if (_tmpAnswersCollection_1 == null) { | |
_tmpAnswersCollection_1 = new ArrayList<AnswerEntity>(); | |
} | |
_item = new QuestionWithRelations(_tmpQuestion,_tmpOptionsCollection_1,_tmpAnswersCollection_1); | |
_result.add(_item); | |
} | |
return _result; | |
} finally { | |
_cursor.close(); | |
} | |
} | |
@Override | |
protected void finalize() { | |
_statement.release(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment