-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
你好 queryFirst 关联查询报错 #100
Comments
Relationship 是一个数组,正确的用法如下: Relationship[] relationships = new Relationship[]{ MeeMeeting.HAS_MANY_MEE_CHATS };
MeeMeeting m = MeeMeeting.queryFirst("mee_id > ?", relationships, 1L); |
麻烦再问一下, 设置Queryable得时候,怎么对应到字段,现在都是用实体去组sql
|
@forgottor 请贴出你生成的SQL,还有你使用的版本信息,Tables.java#144 行的代码如下,你也可以调试一下,逻辑应该是对的: public static final String getColumnName(Class tableClass, String fieldName) {
try {
Field field = tableClass.getDeclaredField(fieldName);
Column column = field.getDeclaredAnnotation(Column.class);
if (column != null) {
if (!StringUtil.isEmpty(column.name())) {
return column.name();
}
}
return tableNameEncoder.getColumnName(tableClass, field.getName());
} catch (NoSuchFieldException ex) {
throw new IllegalStateException(ex.getMessage(), ex);
}
} |
你好 这是我用得版本和自动生成得代码 public static final MeeMeeting queryByMeeName(String value, Relationship... relations) throws SQLException { |
你可以在 getColumnName 方法中,断点调试一下,跟踪一下结果就应该知道原因了,晚点,我在本地测试一下,并增加一个这块的单元测试 |
getColumnName 得结果是对的mee_name,可是这块代码 |
对不起,是我的生成代码的错,之前单元测试没有覆盖这种场景,我修改一下代码,今晚发个最新版本。 |
好的 麻烦了 |
MeeMeeting m = MeeMeeting.queryFirst("mee_id > ?", MeeMeeting.HAS_MANY_MEE_CHATS,1L)
@relation(relationType = RelationType.HAS_MANY,foreignKey = "meeting_id",foreignFieldName = "meetingId")
private List meeChats;
Invalid argument value: java.io.NotSerializableException Query: SELECT * FROM
mee_meeting
WHERE mee_id > ? Parameters: [com.github.braisdom.objsql.relation.Relationship@3d534f26, 1]The text was updated successfully, but these errors were encountered: