title: Object reference across beans
body: <p>Today I came across one situation, here it is.</p>
  
  <p>I have a db object to persist. I use <code>SampleBean.add</code> method. Inside that method, I'm getting primary key from a sequence, setting it to db object's id property and persisting it to db (using <code>PreparedStatement</code>). But I could not get the db object's id property (it comes as 0, even though it got set in persisting method) from the method I'am calling that bean method.</p>
  
  <p>Please clarify me this.  </p>
  
  <p>DB Object </p>
  
  <pre><code>public class LogRow implements Serializable {
       public long cardLogId;
       public String data;
  }
  </code></pre>
  
  <p>Persist method</p>
  
  <pre><code>public void insertLogRow(LogRow logRow) {
          Connection con = null;
          PreparedStatement ps = null;        
          try {
              String insertSql = LogRow.INSERT_LOG;
              con = global.getConnection();
              if (logger.isEnabled(IMessage.DEBUG1)) {
                  logger.println(IMessage.DEBUG1, CLASS_NAME + "insertLogRow():: insertSql " + insertSql);
              }
              ps = con.prepareStatement(insertSql);
              logRow.setLogId(seq.getNextVal());
              ps.executeUpdate(); 
          } catch (SQLException sqe) {          
              logger.println("insertLogRow():: SQLException occurred");
              throw new ProcessingErrorException(sqe.getMessage());
          } 
  }
  </code></pre>
  
  <p>I am able to see the persisted id value here in persist method.</p>
  
  <p>Calling method</p>
  
  <pre><code>RemoteLookup.getSampleBean().insertLogRow(logRow);
  log.println("log id " + logRow.logId());
  </code></pre>
  
  <p>This calling method prints <code>0</code></p>