Java SqlDelight未为SQL语句生成SQL查询字符串
在中的示例中,SqlDelight从HockeyPlayer.sq文件生成的HockeyPlayerModel在抽象类公共抽象类HockeyPlayer implements HockeyPlayerModel中实现 在这个类中,字符串SELECT_ALL_INFO作为查询传递给db.rawQuerySELECT_ALL_INFO,新字符串[0]。字符串SELECT_ALL_INFO是由HockeyPlayer.sq中的SELECT_ALL_INFO语句生成的。但是,在我的情况下,我的语句不会生成字符串。为什么会这样 我的声明Java SqlDelight未为SQL语句生成SQL查询字符串,java,android,sqlite,stored-procedures,sqldelight,Java,Android,Sqlite,Stored Procedures,Sqldelight,在中的示例中,SqlDelight从HockeyPlayer.sq文件生成的HockeyPlayerModel在抽象类公共抽象类HockeyPlayer implements HockeyPlayerModel中实现 在这个类中,字符串SELECT_ALL_INFO作为查询传递给db.rawQuerySELECT_ALL_INFO,新字符串[0]。字符串SELECT_ALL_INFO是由HockeyPlayer.sq中的SELECT_ALL_INFO语句生成的。但是,在我的情况下,我的语句不会生
names_for_groups:
SELECT DISTINCT name, exercise_set_group FROM exercise_set JOIN exercises
USING (exercise_id) WHERE workout_FK = ? ORDER BY exercise_set_group ASC ;
我对SqlDelight生成的ExerciseSetModel的实现
@AutoValue
public abstract class DbExerciseSet implements ExerciseSetModel, DbItem {
public static final Factory<DbExerciseSet> FACTORY = new Factory<>(AutoValue_DbExerciseSet::new);
public static final RowMapper<DbExerciseSet> MAPPER = FACTORY.select_allMapper();
public static final RowMapper<NamesForGroups> NAMES_FOR_GROUPS_MAPPER =
FACTORY.names_for_groupsMapper(AutoValue_DbExerciseSet_NamesForGroups::new);
public List<NamesForGroups> namesForGroups(SQLiteDatabase db) {
List<NamesForGroups> namesForGroupsList= new ArrayList<>();
Cursor cursor = db.rawQuery(NAMES_FOR_GROUPS, new String[0]);
while (cursor.moveToNext() && NAMES_FOR_GROUPS_MAPPER.map(cursor) != null) {
//NamesForGroups namesForGroups = NAMES_FOR_GROUPS_MAPPER.map(cursor);
namesForGroupsList.add(NAMES_FOR_GROUPS_MAPPER.map(cursor));
}
return namesForGroupsList;
}
@AutoValue
public abstract static class NamesForGroups implements Names_for_groupsModel {}
@AutoValue
public abstract static class Exercises implements ExerciseModel {}
}
需要说明的是,在db.rawQueryNAMES\u行中找不到\u组的变量引用名称\u,新字符串[0]需要更新文档,我会这样做。我们不再在SQLDelight 0.6中生成字符串。相反,工厂中有一个方法返回用于查询的SQLDelight语句:
public List<NamesForGroups> namesForGroups(SQLiteDatabase db) {
List<NamesForGroups> namesForGroupsList= new ArrayList<>();
SQLDelightStatement query = FACTORY.name_for_groups();
Cursor cursor = db.rawQuery(query.statement, query.args);
while (cursor.moveToNext() && NAMES_FOR_GROUPS_MAPPER.map(cursor) != null) {
//NamesForGroups namesForGroups = NAMES_FOR_GROUPS_MAPPER.map(cursor);
namesForGroupsList.add(NAMES_FOR_GROUPS_MAPPER.map(cursor));
}
return namesForGroupsList;
}
文件更改的全拉请求:非常感谢;我为此绞尽脑汁有一段时间了