Note that there are some explanatory texts on larger screens.

plurals
  1. POBCED pattern - entity loader method
    primarykey
    data
    text
    <p>I have to attend a "software engineering" exam this Friday, but there's a little thing I can't understand, and my teacher is unavailable for explaining.</p> <p>I must make a project based on the Boundary-Controller-Entity (BCE) pattern, with persistence (database or sequential file, but I'm going to use SQLite). I should implement entity classes with save/load methods, which put/retrieve data in/from the persistence layer. They use DAO.</p> <p>For example:</p> <pre><code>public class someEntity { private int someData; public void set_someData (int _someData) {this.someData = _someData;} public int get_someData () {return this.someData;} public void save () { DAO dao = new DAO (); dao.openConnection (); dao.insert (this.someData); dao.closeConnection (); } </code></pre> <p>Thus far, it's all clear.</p> <p>When I implement the "load" method, I want to "fill" my entity instance with data from the database, using search parameters (primary key in DB). But, if, for example, I want to get all people born before 1980, what can I do?</p> <p>The only solution in my mind is to implement the following, into controller class</p> <pre><code>ArrayList &lt;people&gt; pList= new ArrayList (); people p; for (int i = 1900 ; i &lt; 1980 ; i++) { p = new people (); if (p.load (i) == true); //returns true if has found corresponding entry in db { pList.add(i); } } </code></pre> <p>This is totally insane, is it not?</p> <p>So, I need a "loader" method that returns a collection, so I can implement in the DAO a method that returns all people born before 1980, with a simple SQL query. Can this be done only if the control class talks directly with the DAO, ignoring BCE pattern rules. </p> <p>How can I resolve the problem, if it is a real problem?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload