|
| 1 | +/* |
| 2 | + Copyright (c) 2024, Oracle and/or its affiliates. |
| 3 | +
|
| 4 | + This software is dual-licensed to you under the Universal Permissive License |
| 5 | + (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License |
| 6 | + 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose |
| 7 | + either license. |
| 8 | +
|
| 9 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | + you may not use this file except in compliance with the License. |
| 11 | + You may obtain a copy of the License at |
| 12 | +
|
| 13 | + https://www.apache.org/licenses/LICENSE-2.0 |
| 14 | +
|
| 15 | + Unless required by applicable law or agreed to in writing, software |
| 16 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | + See the License for the specific language governing permissions and |
| 19 | + limitations under the License. |
| 20 | +*/ |
| 21 | + |
| 22 | +package com.oracle.dev.springdata.jdbc; |
| 23 | + |
| 24 | +import java.util.Objects; |
| 25 | + |
| 26 | +import org.springframework.data.annotation.Id; |
| 27 | +import org.springframework.data.relational.core.mapping.Table; |
| 28 | + |
| 29 | +@Table |
| 30 | +public class Employee { |
| 31 | + |
| 32 | + private @Id Long id; |
| 33 | + private String name; |
| 34 | + private String job; |
| 35 | + private Integer salary; |
| 36 | + private Integer commission; |
| 37 | + |
| 38 | + public Employee() { |
| 39 | + } |
| 40 | + |
| 41 | + public Employee(Long id, String name, String job, Integer salary, |
| 42 | + Integer commission) { |
| 43 | + this.id = id; |
| 44 | + this.name = name; |
| 45 | + this.job = job; |
| 46 | + this.salary = salary; |
| 47 | + this.commission = commission; |
| 48 | + } |
| 49 | + |
| 50 | + public Long getId() { |
| 51 | + return id; |
| 52 | + } |
| 53 | + |
| 54 | + public void setId(Long id) { |
| 55 | + this.id = id; |
| 56 | + } |
| 57 | + |
| 58 | + public String getName() { |
| 59 | + return name; |
| 60 | + } |
| 61 | + |
| 62 | + public void setName(String name) { |
| 63 | + this.name = name; |
| 64 | + } |
| 65 | + |
| 66 | + public String getJob() { |
| 67 | + return job; |
| 68 | + } |
| 69 | + |
| 70 | + public void setJob(String job) { |
| 71 | + this.job = job; |
| 72 | + } |
| 73 | + |
| 74 | + public Integer getSalary() { |
| 75 | + return salary; |
| 76 | + } |
| 77 | + |
| 78 | + public void setSalary(Integer salary) { |
| 79 | + this.salary = salary; |
| 80 | + } |
| 81 | + |
| 82 | + public Integer getCommission() { |
| 83 | + return commission; |
| 84 | + } |
| 85 | + |
| 86 | + public void setCommission(Integer commission) { |
| 87 | + this.commission = commission; |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public int hashCode() { |
| 92 | + return Objects.hash(commission, id, job, name, salary); |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public boolean equals(Object obj) { |
| 97 | + if (this == obj) |
| 98 | + return true; |
| 99 | + if (obj == null) |
| 100 | + return false; |
| 101 | + if (getClass() != obj.getClass()) |
| 102 | + return false; |
| 103 | + Employee other = (Employee) obj; |
| 104 | + return Objects.equals(commission, other.commission) |
| 105 | + && Objects.equals(id, other.id) && Objects.equals(job, other.job) |
| 106 | + && Objects.equals(name, other.name) |
| 107 | + && Objects.equals(salary, other.salary); |
| 108 | + } |
| 109 | + |
| 110 | + public String toString() { |
| 111 | + return String.format("%20s %20s %20s %20s %20s", id, name, job, salary, |
| 112 | + commission); |
| 113 | + |
| 114 | + } |
| 115 | +} |
0 commit comments