mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#399 - ENH: Add new Finder ... to effectively replace Model.Finder
This commit is contained in:
@@ -5,6 +5,7 @@ import com.avaje.ebean.annotation.ChangeLogInsertMode;
|
||||
import com.avaje.ebean.annotation.EnumValue;
|
||||
import com.avaje.ebean.annotation.JsonIgnore;
|
||||
import com.avaje.ebean.annotation.Where;
|
||||
import com.avaje.tests.model.basic.finder.CustomerFinder;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
@@ -29,6 +30,8 @@ public class Customer extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final CustomerFinder find = new CustomerFinder();
|
||||
|
||||
/**
|
||||
* EnumValue is an Ebean specific mapping for enums.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.avaje.tests.model.basic.finder;
|
||||
|
||||
import com.avaje.ebean.Finder;
|
||||
import com.avaje.tests.model.basic.Customer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Finder methods for Customer.
|
||||
*/
|
||||
public class CustomerFinder extends Finder<Integer,Customer> {
|
||||
|
||||
public CustomerFinder() {
|
||||
super(Customer.class);
|
||||
}
|
||||
|
||||
public CustomerFinder(String serverName) {
|
||||
super(Customer.class, serverName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find customer by unique name.
|
||||
*/
|
||||
@Nullable
|
||||
public Customer byName(String name) {
|
||||
|
||||
return query().where().eq("name", name).findUnique();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user