Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Put all fields in its own class, also called an entity or DTO class (e.g. <code>User</code>, <code>Product</code>, <code>Order</code>, etc) and reference it instead. Those can be JDBC/JPA entities. Put all business methods in its own class, also called a service or domain object (e.g. <code>UserService</code>, <code>ProductService</code>, etc) and reference it instead. Those can be EJB's.</p> <p>E.g. thus not</p> <pre><code>public class Bean { private Long id; private String field1; private String field2; private String field3; // Etc... All model fields. @PostConstruct public void init() { // &gt;20 lines of business/domain code to prefill the fields from DB. } public void save() { // &gt;20 lines of business/domain code to save the fields in DB. } // Getters/setters for all fields and possibly also all nested fields. } </code></pre> <p>But more so</p> <pre><code>public class Bean { private Long id; private Entity entity; @EJB private EntityService service; @PostConstruct public void init() { entity = service.find(id); } public void save() { service.save(entity); } // Getter/setter for id and getter for entity. } </code></pre> <p>Further, I've also seen code wherein the nested objects/entities are delegated through by additional getters/setters in the bean like so</p> <pre><code>private Entity entity; public String getField1() { return entity.getField1(); } public void setField1(String field1) { entity.setField1(field1); } // Etc... </code></pre> <p>This is totally unnecessary. Just a single getter for the entity is sufficient (setter is not mandatory!), in combination with</p> <pre class="lang-html prettyprint-override"><code>&lt;h:inputText value="#{bean.entity.field1}" /&gt; </code></pre> <p>The entities at its own can also be further divided. E.g. <code>street</code>, <code>houseNumber</code>, <code>zipCode</code>, <code>city</code>, <code>country</code> of an <code>User</code> could be replaced by another entity/DTO <code>Address</code> within the same <code>User</code>.</p> <hr> <p>If you have bad luck, the code has been autogenerated by a visual editor (e.g. Netbeans + Woodstock). There's not much to refactor anyway without completely redesigning it, I would rather look for another project.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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