anonymous wrote : 
  | go for logical equality, so if your entity has three fields:
  | Code:
  | 
  |   | @Id
  |   | @GeneratedValue
  |   | private int id;
  |   | private String firstName;
  |   | private String lastName;        
  |   | 
  | 
  | 
  | then equals/hashCode should be based on first/lastName and not id.
  | 

I understand this concept as you have put forth.  That being that a firstName & 
lastName has some uniqueness.
This issue occurs in my mind when you have 2 Joe Smiths.
These to object are then considered equal when they may not actually
be EQUAL in reality.  So to then you would say add SSN or some other
unique.  Which in all reality replaces the Primary key.  This works for
objects with such unique identifier.

Unfortunately with objects such as a Order Line where the structure are as 
follows:

  |  @Id
  |  @GeneratedValue(strategy = GenerationType.SEQUENCE)
  |  private Long id;
  |  private String lineStatus = OrderLine.SHIP_WHEN_COMP;
  |  @Temporal(TemporalType.TIMESTAMP)
  |  private Calendar requiredDate;
  |  private LineQuantity quantity;
  |  @Embedded    
  |  private PriceCost priceCost;
  |  @OneToOne(cascade = CascadeType.ALL)
  |  private Item item;
  |  @ManyToOne
  |  @JoinColumn(name="parentOrder")
  |  private Order parentOrder;
  | 
Business unique identifiers do not exist.

Two order lines where all attribute values are equal can exist on the same 
parent order.  

Does anyone have a example of how to resolve THIS specific issue?

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106132#4106132

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106132
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to