来自Hibernate的Scout SmartField建议

时间:2014-06-26 14:54:37

标签: sql hibernate service drilldown eclipse-scout

我在Scout工作,需要SmartField。为此,我需要设置查找建议。

我看到创建Lookup Call的示例,而不是在Lookup Service getConfiguredSqlSelect

中实现

但我使用Hibernate来处理类,所以我的问题是如何将智能字段与Hibernate对象填充服务连接起来?

1 个答案:

答案 0 :(得分:1)

根据[1]创建一个新的查找调用,但有以下不同之处:

  1. 不要选择AbstractSqlLookupService作为查找服务超类型,但是AbstractLookupService
  2. 在关联的查找服务中,您现在需要实现getDataByAll,getDataByKey和getDataByText
  3. 说明以下代码段应该有所帮助:

    public class TeamLookupService extends AbstractLookupService<String> implements ITeamLookupService {
    
      private List<ILookupRow<String>> m_values = new ArrayList<>();
    
      public TeamLookupService() {
        m_values.add(new LookupRow<String>("CRC", "Costa Rica"));
        m_values.add(new LookupRow<String>("HON", "Honduras"));
        m_values.add(new LookupRow<String>("MEX", "Mexico"));
        m_values.add(new LookupRow<String>("USA", "USA"));
      }
    
      @Override
      public List<? extends ILookupRow<String>> getDataByAll(ILookupCall<String> call) throws ProcessingException {
        return m_values;
      }
    
      @Override
      public List<? extends ILookupRow<String>> getDataByKey(ILookupCall<String> call) throws ProcessingException {
        List<ILookupRow<String>> result = new ArrayList<>();
    
        for (ILookupRow<String> row : m_values) {
          if (row.getKey().equals(call.getKey())) {
            result.add(row);
          }
        }
    
        return result;
      }
      ...
    

    [1] https://wiki.eclipse.org/Scout/Tutorial/4.0/Minicrm/Lookup_Calls_and_Lookup_Services#Create_Company_Lookup_Call

相关问题