JoinClause - 无效语句。请检查别名、字段标识符、投影和查询条件
JoinClause - Invalid statement. Please check aliases, field identifiers, projections and query conditions
我正在使用 Dynamicloud,但我的代码有问题:
这是我的代码:
RecordModel contactFormModel = new RecordModel(contactModelId);
RecordModel userFormModel = new RecordModel(userContactModelId);
DynamicProvider<ContactForm> provider = new DynamicProviderImpl<ContactForm>(new RecordCredential(csk, aci));
contactFormModel.setBoundClass(ContactForm.class);
Query<ContactForm> query = provider.createQuery(contactFormModel);
query.setAlias("contact");
query.setProjection("contact.namef, contact.comments");
JoinClause join = Conditions.innerJoin(userFormModel, "user", "contact.id = user.contactid");
query.join(join);
try {
RecordResults<ContactForm> list = query.add(Conditions.like("contact.namef", "ProBusiness%")).list();
System.out.println("list = " + list.getFastReturnedSize());
if (list.getFastReturnedSize() > 0) {
System.out.println("Contact Name = " + list.getRecords().get(0).getName());
System.out.println("Contact Comments = " + list.getRecords().get(0).getComments());
}
} catch (DynamicloudProviderException e) {
e.printStackTrace();
}
此代码抛出以下异常:
org.dynamicloud.exception.DynamicloudProviderException: Invalid statement. Please check aliases, field identifiers, projections and query conditions.
怎么了?
谢谢!
嗨
问题是您的投影部分缺少 "id"。您需要设置您的JoinClause中涉及的一个模型的id。
Dynamicloud 始终按 Id 对结果进行排序,在这种情况下,查询具有不明确的列 user.id
和 contact.id"
试试把下面的id放到你的projection中(当然要看你的需要):
query.setProjection("contact.id, contact.namef, contact.comments");
希望对您有所帮助!
我正在使用 Dynamicloud,但我的代码有问题:
这是我的代码:
RecordModel contactFormModel = new RecordModel(contactModelId);
RecordModel userFormModel = new RecordModel(userContactModelId);
DynamicProvider<ContactForm> provider = new DynamicProviderImpl<ContactForm>(new RecordCredential(csk, aci));
contactFormModel.setBoundClass(ContactForm.class);
Query<ContactForm> query = provider.createQuery(contactFormModel);
query.setAlias("contact");
query.setProjection("contact.namef, contact.comments");
JoinClause join = Conditions.innerJoin(userFormModel, "user", "contact.id = user.contactid");
query.join(join);
try {
RecordResults<ContactForm> list = query.add(Conditions.like("contact.namef", "ProBusiness%")).list();
System.out.println("list = " + list.getFastReturnedSize());
if (list.getFastReturnedSize() > 0) {
System.out.println("Contact Name = " + list.getRecords().get(0).getName());
System.out.println("Contact Comments = " + list.getRecords().get(0).getComments());
}
} catch (DynamicloudProviderException e) {
e.printStackTrace();
}
此代码抛出以下异常:
org.dynamicloud.exception.DynamicloudProviderException: Invalid statement. Please check aliases, field identifiers, projections and query conditions.
怎么了?
谢谢!
嗨
问题是您的投影部分缺少 "id"。您需要设置您的JoinClause中涉及的一个模型的id。
Dynamicloud 始终按 Id 对结果进行排序,在这种情况下,查询具有不明确的列 user.id
和 contact.id"
试试把下面的id放到你的projection中(当然要看你的需要):
query.setProjection("contact.id, contact.namef, contact.comments");
希望对您有所帮助!