本文介绍了通过DQL从documentum检索一行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的列表视图中有一个用户列表,通过从documentum检索数据来填充。如果我点击这个最少的任何一行(每行代表一个用户),我应该能够看到他们列出的所有信息。(这是我的问题

I have a list of users in my list view which is populated by retrieving data from documentum . If I click on any row of this least (each row represent one user) I should be able to see all of their information listed down .(This is my problem )

public void selectedItemFromListView(){
     selected = lwAllUserGrp.getSelectionModel().getSelectedItem();
     System.out.println(selected);
     String query =" select * from dm_user where user_name = '@aclName'" ;
     String test = query.replace("@aclname", selected);

     GetDataWithDqlProfile(_session , query , "user_login_name" , "user_address" , "user_state" );
     System.out.println(user.getAddress());
     System.out.println(user.getState());
     System.out.println(user.getUsername());

}

如果我点击一行列表视图我就能成功看看谁被选中,我需要通过DQL从documentum中检索该用户名(同一个人)的所有其他属性。

if I click on a row of list view I can successfully see who is selected and I need to retrieve all the other attributes of that username (same person) from documentum via DQL .

private void GetDataWithDqlProfile(IDfSession session, String Query, String username , String address , String state ) {

    try {
        IDfQuery UpdateQuery = new DfQuery();
        UpdateQuery.setDQL(Query);
        IDfCollection col = UpdateQuery.execute(_session, IDfQuery.DF_QUERY);


            user.setAddress(col.getString(username));
            user.setUsername(col.getString(address));
            user.setState(col.getString(state));

        col.close();
    } catch (Exception e) {
        Alert alert = new Alert(Alert.AlertType.ERROR, e.getMessage());
        alert.showAndWait();
        Logs.WriteLog(LoginController.Repository + ",User:" + LoginController.Username, "DQL Query", e.toString());
        e.getStackTrace();
    }

我的输出是:

User's name 
null
null 
null 

我在DQL测试器中尝试过DQL查询,效果很好

推荐答案

对于你们之后提到这个问题的人我是如何解决这个问题的:

For those of you referring to this question later here is how I solved the problem :

public ArrayList<User> GetDataWithDqlpro(IDfSession session, String Query, String username , String state , String address) {

    try {
        IDfQuery UpdateQuery = new DfQuery();
        UpdateQuery.setDQL(Query);
        IDfCollection col = UpdateQuery.execute(_session, IDfQuery.DF_QUERY);

        while (col.next()) {
            list.add( new User(col.getString(username),col.getString(address) , col.getString(state)));

        }
        col.close();

    }catch (Exception e) {
            Alert alert = new Alert(Alert.AlertType.ERROR, e.getMessage());
            alert.showAndWait();
            Logs.WriteLog(LoginController.Repository + ",User:" + LoginController.Username, "DQL Query", e.toString());
            e.getStackTrace();
}
        return (ArrayList<User>) list;

}



public void selectedItemFromListView(){
     selected = lwAllUserGrp.getSelectionModel().getSelectedItem();
     System.out.println(selected);
     String Query = "select user_login_name , user_state , user_address from dm_user where user_login_name ='@aclname'";
     Query = Query.replace("@aclname",selected );
     ArrayList<User> allUserNames = GetDataWithDqlpro(_session, Query, "user_login_name","user_address","user_state");
     for (int i = 0 ; i <= allUserNames.size()-1 ; i++ ){
         if (selected.compareToIgnoreCase(allUserNames.get(i).getUsername() ) == 0){
                System.out.println(allUserNames.get(i).getState() );
                System.out.println(allUserNames.get(i).getAddress() );
                System.out.println(allUserNames.get(i).getUsername() );

         }

     }

}

值得一提的是,我有一个名为User with class with constructor and get and set methods

Worth mentioning that I have a class called User with constructor and get and set methods

我希望它将帮助一些人:)

这篇关于通过DQL从documentum检索一行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 12:47