From 7870a7e060eb31b3ba62de03d2d15a108b367734 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Mon, 19 Jun 2017 09:51:03 +0200 Subject: [PATCH] #278 - Fix entity characteristics in Customer in Eclipselink example. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now calculate the equals(…) and hashCode() methods by looking at the indentifier only. Removed default constructor in favor of Lombok's @NoArgConstructor. --- .../springdata/jpa/eclipselink/Customer.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/Customer.java b/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/Customer.java index 7754aee6..68a7efe8 100644 --- a/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/Customer.java +++ b/jpa/eclipselink/src/main/java/example/springdata/jpa/eclipselink/Customer.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,26 +15,26 @@ */ package example.springdata.jpa.eclipselink; +import lombok.AccessLevel; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.RequiredArgsConstructor; + import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; -import lombok.Data; -import lombok.RequiredArgsConstructor; - /** * @author Oliver Gierke */ @Data @Entity +@EqualsAndHashCode(of = "id") @RequiredArgsConstructor +@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) public class Customer { private @Id @GeneratedValue Long id; private final String firstname, lastname; - - Customer() { - this.firstname = null; - this.lastname = null; - } }