The broker.getObjectByQuery seems to be selecting but not returning data
from a table that contains the exact data that I am querying for.

I apologise that this text is rather long but I am hoping that detaling
the whole issue may help somebody (please) find where I am going wrong?

The scenario is as follows:


I am developing a web application that will be using Oracle as its data
repository. Within the Oracle schema I have a table called CSHETA_USERS as
follows:

CREATE TABLE CSHETA_USERS (
   MEMBER_ID     number  not null,
   USER_NAME     VARCHAR2(20) not null,
   PASS_WORD     VARCHAR2(20) not null,
   FIRST_NAME    VARCHAR2(50),
   LAST_NAME     VARCHAR2(50),
   EMAIL         VARCHAR2(100),
   CONSTRAINT PK_CSHETA_USERS_MEMBER_ID PRIMARY KEY (MEMBER_ID) )

It has the following data in it

INSERT INTO CSHETA_USERS (
   MEMBER_ID,USER_NAME,PASS_WORD,FIRST_NAME,LAST_NAME)
values (
   '1','anonymous','password','A','Nonymous');

INSERT INTO CSHETA_USERS (
   MEMBER_ID,USER_NAME,PASS_WORD,FIRST_NAME,LAST_NAME)
values (
   '2','cshetadm','openup','Csheta','Admin');

I have configured my repository_user.xml file as follows:

------------------- snip -------------------
   <class-descriptor
   class="com.twosquared.csheta.cshetadb.cshetausers.CshetaUsersVO"
     table="CSHETA_USERS">
      <field-descriptor
         id="1"
         name="memberId"
         column="member_id"
         jdbc-type="INTEGER"
         primarykey="true"
         nullable="false"
      />
      <field-descriptor
         id="2"
         name="userName"
         column="user_name"
         jdbc-type="VARCHAR"
         nullable="false"
         length="20"
      />
      <field-descriptor
         id="3"
         name="passWord"
         column="pass_word"
         jdbc-type="VARCHAR"
         nullable="false"
         length="20"
      />
      <field-descriptor
         id="4"
         name="firstName"
         column="first_name"
         jdbc-type="VARCHAR"
         nullable="true"
         length="40"
      />
      <field-descriptor
         id="5"
         name="lastName"
         column="last_name"
         jdbc-type="VARCHAR"
         nullable="true"
         length="50"
      />
      <field-descriptor
         id="6"
         name="email"
         column="email"
         jdbc-type="VARCHAR"
         nullable="true"
         length="100"
      />
   </class-descriptor>

------------------- snip -------------------


I have the following code that tries to select the 'annonymous' user
record from the database by its member_id value ( i.e select * from
csheta_users where memeber_id = '1'

------------------- snip -------------------

          CshetaUsersDAO cshetaUsersDAO = new CshetaUsersDAO();
          cshetaUsersVO = (CshetaUsersVO) cshetaUsersDAO.findByPK("1");

------------------- snip -------------------


the Data Access Object findByPk is as follows:

        public ValueObject findByPK(String primaryKey) throws
        DataAccessException {

            PersistenceBroker broker = null;
            CshetaUsersVO cshetaUsersVO   = null;
        
            try{
              broker = ServiceLocator.getInstance().findBroker();
              cshetaUsersVO = new CshetaUsersVO();
              cshetaUsersVO.setMemberId(new Integer(primaryKey));
        
              Query query = new QueryByCriteria(cshetaUsersVO);
              cshetaUsersVO = (CshetaUsersVO)
              broker.getObjectByQuery(query);
            }
            catch(ServiceLocatorException e){
                log.error("ServiceLocatorException thrown in
                CshetaUsersDAO.findByPK()", e);
               throw new DataAccessException("ServiceLocatorException in
               CshetaUsersDAO.findByPK()",e);
            }
            finally{
              if (broker!=null) broker.close();
            }
            }
            return cshetaUsersVO;
        } // end findByPK



I am debugging the application using eclipse/myeclipseide & oracle
scripts. When I trace the code I can see it successfully build up the
correct criteria to select from the database and by tracing the database I
can see that a select of the appropriate table (csheta_users) has taken
place however after the following line has been executed

              cshetaUsersVO = (CshetaUsersVO)
              broker.getObjectByQuery(query);
 
My Value Object 'cshetaUsersVO' is still null (as if the data doesn't
exist).

I am struggling to debug this further as I can see the database table is
read but I don't think the ojb reflection is calling my getters and
setters within cshetaUsersVO and setting the object with the retrieved
data values.

My cshetaUsersVO object is as follows :

public class CshetaUsersVO extends ValueObject {

    private Integer memberId;
    private String userName;
    private String passWord;
    private String firstName;
    private String lastName;
    private String email;
   
    public CshetaUsersVO() {}

    public CshetaUsersVO(Integer memberId, String userName,
    String passWord,
    String firstName,
    String lastName,
    String email){
        this.memberId  = memberId;
        this.userName  = userName;
        this.passWord  = passWord;
        this.firstName = firstName;
        this.lastName  = lastName;
        this.email = email;
    }
    }
    public Integer getMemberId() {
        return memberId;
    }
    public void setMemberId(Integer memberId) {
        this.memberId = memberId;
    }
    }
------------------- snip -------------------

} // end CshetaUsersVO



I would very much appreciate some help with this as I am rather baffled by
it.

Thank you in advance


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to