Suppose I would like to have a method, which is obtaining super main customer, which has id=0
.
I have Customer class:
@Entity
public class Customer {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private long id;
private String firstName;
private String lastName;
protected Customer() {}
public Customer(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
@Override
public String toString() {
return String.format(
"Customer[id=%d, firstName='%s', lastName='%s']",
id, firstName, lastName);
}
}
According to dox, I should create two additional classes/interfaces.
So I have CustomerCustom
interface:
public interface CustomerCustom {
Customer getVeryMainCustomer();
}
where a method getVeryMainCustomer
declared.
Then my exposure repository interface turns following:
public interface CustomerRepository extends CrudRepository<Customer, Long>, CustomerCustom {
List<Customer> findByLastName(String lastName);
}
it extends both CrudRepository
and my CustomerCustom
.
But next I should implement CustomerCustom
. But how to do that?
I wrote
public class CustomerCustomImpl implements CustomerCustom {
@Override
public Customer getVeryMainCustomer() {
return null;
}
}
bot don't know, what to write in implementation. How to reach customer?