本文整理汇总了Java中org.example.domain.Customer.setName方法的典型用法代码示例。如果您正苦于以下问题:Java Customer.setName方法的具体用法?Java Customer.setName怎么用?Java Customer.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.example.domain.Customer
的用法示例。
在下文中一共展示了Customer.setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInsert
import org.example.domain.Customer; //导入方法依赖的package包/类
@Test
public void testInsert() {
Transaction txn = Customer.db().beginTransaction();
try {
txn.setBatchMode(true);
txn.setBatchSize(10);
// turn of getGeneratedKeys if we don't need to use the
// customer bean instances after we have inserted them
txn.setBatchGetGeneratedKeys(false);
for (int i = 0; i < 40; i++) {
Customer c = new Customer();
c.setName("batch insert test "+i);
c.save();
}
txn.commit();
} finally {
txn.end();
}
}
示例2: test
import org.example.domain.Customer; //导入方法依赖的package包/类
@Test
public void test() {
Customer customer = new Customer();
customer.setName("slash\\monkey");
customer.save();
List<Customer> list = Customer.find.where().eq("name", "slash\\monkey").findList();
Assert.assertEquals("equals with slash", 1, list.size());
list = Customer.find.where().like("name", "slash\\mon%").findList();
Assert.assertEquals("like with slash", 1, list.size());
list = Customer.find.where().raw("name like 'slash\\mon%' escape''").findList();
Assert.assertEquals("like with slash using raw", 1, list.size());
list = Customer.find.where().raw("name like ? escape''", "slash\\mon%").findList();
Assert.assertEquals("like with slash using raw", 1, list.size());
list = Customer.find.where().raw("name like 'slash\\mon%'").findList();
Assert.assertEquals("raw like with no escape - not found", 0, list.size());
}
示例3: test
import org.example.domain.Customer; //导入方法依赖的package包/类
@Test
public void test() {
Ebean.getServer(null);
Customer customer = new Customer();
customer.setName("Rob");
customer.save();
Transaction txn = Customer.db().beginTransaction();
txn.setBatchMode(true);
try {
for (int i = 0; i < 2; i++) {
Customer cust = new Customer();
cust.setName("Batch insert "+i);
cust.save();
}
txn.commit();
} finally {
txn.end();
}
}
示例4: insertCustomerNoContacts
import org.example.domain.Customer; //导入方法依赖的package包/类
private Customer insertCustomerNoContacts(String name) {
Customer c = createCustomer("Roger", "15 Kumera Way", "Bos town", "2010-04-10");
c.setName(name);
c.setStatus(Customer.Status.ACTIVE);
Ebean.save(c);
return c;
}
示例5: insertCustomerNoAddress
import org.example.domain.Customer; //导入方法依赖的package包/类
private Customer insertCustomerNoAddress(String name) {
Customer c = new Customer();
c.setName(name);
c.setStatus(Customer.Status.NEW);
c.addContact(createContact("Jack", "Black"));
Ebean.save(c);
return c;
}
示例6: createCustomer
import org.example.domain.Customer; //导入方法依赖的package包/类
public static Customer createCustomer(String name, String shippingStreet, String billingStreet, String annDate) {
Customer c = new Customer();
c.setName(name);
c.setStatus(Customer.Status.NEW);
if (annDate == null) {
annDate = "2010-04-14";
}
c.setAnniversary(Date.valueOf(annDate));
if (shippingStreet != null) {
Address shippingAddr = new Address();
shippingAddr.setLine1(shippingStreet);
shippingAddr.setLine2("Sandringham");
shippingAddr.setCity("Auckland");
shippingAddr.setCountry(Ebean.getReference(Country.class, "NZ"));
c.setShippingAddress(shippingAddr);
}
if (billingStreet != null) {
Address billingAddr = new Address();
billingAddr.setLine1(billingStreet);
billingAddr.setLine2("St Lukes");
billingAddr.setCity("Auckland");
billingAddr.setCountry(Ebean.getReference(Country.class, "NZ"));
c.setBillingAddress(billingAddr);
}
return c;
}
示例7: update
import org.example.domain.Customer; //导入方法依赖的package包/类
@Test
public void update() {//throws InterruptedException {
Customer cust = server.find(Customer.class)
.where().idEq(2)
.setUseDocStore(true)
.findOne();
cust.setName("Cust NonAddress");
cust.save();
sleepToPropagate();
//Thread.sleep(4000);
List<Order> orders = server.find(Order.class)
.where().eq("customer.id", cust.getId())
.setUseDocStore(true)
.findList();
//Thread.sleep(4000);
for (Order order : orders) {
assertEquals(order.getCustomer().getName(), cust.getName());
}
List<Contact> contacts = server.find(Contact.class)
.where().eq("customer.id", cust.getId())
.setUseDocStore(true)
.findList();
for (Contact contact : contacts) {
assertEquals(contact.getCustomer().getName(), cust.getName());
}
}
示例8: findIterate
import org.example.domain.Customer; //导入方法依赖的package包/类
@Test
public void findIterate() {
Customer cust = new Customer();
cust.setName("foo");
cust.setStatus(Customer.Status.GOOD);
cust.save();
List<Long> ids = new QCustomer()
.status.equalTo(Customer.Status.GOOD)
.findIds();
assertThat(ids).isNotEmpty();
Map<List, Customer> map = new QCustomer()
.status.equalTo(Customer.Status.GOOD)
.findMap();
assertThat(map.size()).isEqualTo(ids.size());
QueryIterator<Customer> iterate = new QCustomer()
.status.equalTo(Customer.Status.GOOD)
.findIterate();
try {
while (iterate.hasNext()) {
Customer customer = iterate.next();
customer.getName();
}
} finally {
iterate.close();
}
}
示例9: insertCustomerNoContacts
import org.example.domain.Customer; //导入方法依赖的package包/类
private Customer insertCustomerNoContacts(String name) {
Customer c = createCustomer("Roger", "15 Kumera Way", "Bos town", 1);
c.setName(name);
Ebean.save(c);
return c;
}
示例10: insertCustomerNoAddress
import org.example.domain.Customer; //导入方法依赖的package包/类
private Customer insertCustomerNoAddress() {
Customer c = new Customer();
c.setName("Cust NoAddress");
c.addContact(createContact("Jack", "Black"));
Ebean.save(c);
return c;
}
示例11: createCustomer
import org.example.domain.Customer; //导入方法依赖的package包/类
public static Customer createCustomer(String name, String shippingStreet, String billingStreet, int contactSuffix) {
Customer c = new Customer();
c.setName(name);
if (contactSuffix > 0) {
c.addContact(new Contact("Jim" + contactSuffix, "Cricket"));
c.addContact(new Contact("Fred" + contactSuffix, "Blue"));
c.addContact(new Contact("Bugs" + contactSuffix, "Bunny"));
}
if (shippingStreet != null) {
Address shippingAddr = new Address();
shippingAddr.setLine1(shippingStreet);
shippingAddr.setLine2("Sandringham");
shippingAddr.setCity("Auckland");
shippingAddr.setCountry(Ebean.getReference(Country.class, "NZ"));
c.setShippingAddress(shippingAddr);
}
if (billingStreet != null) {
Address billingAddr = new Address();
billingAddr.setLine1(billingStreet);
billingAddr.setLine2("St Lukes");
billingAddr.setCity("Auckland");
billingAddr.setCountry(Ebean.getReference(Country.class, "NZ"));
c.setBillingAddress(billingAddr);
}
return c;
}
示例12: testInsert
import org.example.domain.Customer; //导入方法依赖的package包/类
@Test
public void testInsert() {
Customer customer = new Customer();
customer.setName("John");
Map<String,String> tags = new HashMap<>();
tags.put("height","100");
tags.put("length","400");
tags.put("trim","large");
customer.setTags(tags);
customer.save();
Customer customer2 = new Customer();
customer2.setName("Ringo");
Map<String,String> tags2 = new HashMap<>();
tags2.put("height","150");
tags2.put("length","400");
customer2.setTags(tags2);
customer2.save();
List<Customer> all = Customer.find.all();
for (Customer cust : all) {
System.out.println(cust);
}
// find John but not Ringo ...
List<Customer> some = Customer.find.where()
.raw("defined(tags,'trim')")
.findList();
for (Customer largeHeight : some) {
System.out.println(largeHeight);
}
}
示例13: testModifyWithPutAndClear
import org.example.domain.Customer; //导入方法依赖的package包/类
@Test
public void testModifyWithPutAndClear() {
Customer customer = new Customer();
customer.setName("diff on map");
Map<String,String> tags = new HashMap<>();
tags.put("height","100");
customer.setTags(tags);
customer.save();
Customer custToMod = Customer.find.byId(customer.getId());
Assert.assertEquals(Long.valueOf(1), Long.valueOf(custToMod.getVersion()));
Map<String, String> tags2 = custToMod.getTags();
tags2.put("length", "200");
tags2.put("height", "23");
System.out.println("-- update after put new values...");
custToMod.update();
Assert.assertEquals(Long.valueOf(2), Long.valueOf(custToMod.getVersion()));
custToMod.getTags().clear();
System.out.println("-- update after a clear ...");
custToMod.save();
Assert.assertEquals(Long.valueOf(3), Long.valueOf(custToMod.getVersion()));
}
示例14: testInsert
import org.example.domain.Customer; //导入方法依赖的package包/类
@Transactional
@Test
public void testInsert() throws IOException {
Customer customer = new Customer();
customer.setName("Frankie");
Map<String,String> tags = new HashMap<>();
tags.put("height","100");
tags.put("length","400");
tags.put("trim","large");
tags.put("colour","red");
customer.setTags(tags);
customer.save();
Assert.assertNotNull(customer.getId());
String json = Ebean.json().toJson(customer);
System.out.println(json);
Customer customer1 = Ebean.json().toBean(Customer.class, json);
assertEquals(customer.getId(), customer1.getId());
assertEquals(customer.getName(), customer1.getName());
assertEquals(customer.getTags().size(), customer1.getTags().size());
assertEquals(customer.getTags().get("height"), customer1.getTags().get("height"));
assertEquals("400", customer1.getTags().get("length"));
assertEquals("large", customer1.getTags().get("trim"));
Customer customer2 = Customer.find.byId(customer.getId());
assertEquals(customer.getId(), customer2.getId());
assertEquals(customer.getName(), customer2.getName());
assertEquals(customer.getTags().size(), customer2.getTags().size());
assertEquals(customer.getTags().get("height"), customer2.getTags().get("height"));
assertEquals("400", customer2.getTags().get("length"));
assertEquals("large", customer2.getTags().get("trim"));
customer.setTags(new HashMap<String, String>());
String jsonWithEmpty = Ebean.json().toJson(customer);
System.out.println("WITH EMPTY-> "+jsonWithEmpty);
Customer customerWithEmpty = Ebean.json().toBean(Customer.class, jsonWithEmpty);
assertEquals(0, customerWithEmpty.getTags().size());
customer.setTags(null);
String jsonWithNull = Ebean.json().toJson(customer);
System.out.println("WITH NULL-> " + jsonWithNull);
Customer customerWithNull = Ebean.json().toBean(Customer.class, jsonWithNull);
assertNull(customerWithNull.getTags());
}
示例15: test
import org.example.domain.Customer; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
Customer customer = new Customer();
customer.setName("SomeCustomer");
Map<String,String> tags = new HashMap<>();
tags.put("height","100");
tags.put("length","200");
customer.setTags(tags);
JsonContext jsonContext = Customer.db().json();
String jsonString = jsonContext.toJson(customer);
System.out.println(jsonString);
}