Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I read in one of the comments to the question that you are letting Eclipse generate the <code>equals</code> and <code>hashCode</code> methods.</p> <p>Did you do that for all the entities (<code>Part</code> and <code>Compound</code>)? I'm asking because if that's the case, those methods generally directly access the object properties (i.e. without calling the getter methods). They look like the following.</p> <pre><code>@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((prop == null) ? 0 : prop.hashCode()); return result; } </code></pre> <p>When using Hibernate, that often leads to problems like the one you are describing, because the uninitialized properties have default values (<code>null</code> for Objects, 0 for <code>int</code>s, and so on) <strong>until the appropriate get method is called</strong>, which causes the hibernate proxy to access the database and load the values you need to compute the proper values for the methods.</p> <p>You can easily spot the problem if you fire up a debugger and inspect the properties on the first call to <code>hashCode()</code>.</p> <p>If that happens, the easiest way to fix this is to modify your methods to use the get methods, like here:</p> <pre><code>@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((getProp() == null) ? 0 : getProp().hashCode()); return result; } </code></pre> <p>Another point worth noting: the Eclipse-generated equals method contains performs this check <code>getClass() != obj.getClass()</code> which is not appropriate for Hibernate entities which are extended by Hibernate proxies. I would replace that with an <code>instanceof</code> check.</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. 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