Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. COHello ! Thanks for the insight. I understand that IDE can help generating it, and there is jakarta common lang EqualsBuilder or HashCodeBuilder for that. But i were just thinking whether it's a bad idea to skip it if im satisfied with the default Object.equals() and Object.hashCode(), using the == for equality. Because once i decide to implement eq/hC, that adds a bit of cost of implementation and future maintenance. Your arguments make sense, but what about the business key fields that can be changed ? I think although most business key fields wont change, but perhaps some can change ?
      singulars
    2. COBusiness keys *can* change, and that's fine. That's why you are using a surrogate key :-) But usually, if the business key change to add a new property to the key, it means that your application will be redeployed. Thus, there's no problem there, as all existing objects will leave the JVM and will be loaded with the new property. And if a specific object has its own business key changed, it means it's not equal anymore to other objects with the same business key. Which is quite appropriate. So, you have nothing to lose by implementing equals/hashCode.
      singulars
    3. COSorry for not being clear with my latest response. I was thinking about modifying an already existing record in db. Because according to the article, using the id in eq/hC is not enough in some cases for hibernate, so the eq/hC based on business key fields is introduced. So, i was thinking, if the business key values can be changed, how can i find the old entity inside a collection that still have the old business key values and then replace it with the new values ? This seems that i have to use the id instead to be able to locate the old entity and change the business key values.
      singulars
 

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