var c = new Customer(); c instanceof Customer; //Returns true as c is just a customer c instanceof String; //Returns false as c is not a string, it's a customer silly!
EntityManager em = ...; EntityTransaction tx = em.getTransaction(); tx.begin(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); em.persist(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: em.flush(); em.clear(); } } tx.commit(); session.close();
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
Gson g = ...; String jsonString = g.toJson(new Customer());
Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } } tx.commit(); session.close();
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_top); Customer cust=new Customer(); cust.setName("abc"); cust.setCity("xyz"); Intent intent=new Intent(abc.this,xyz.class); intent.putExtra("bundle",cust); startActivity(intent); }
Collection<Customer> data = new ArrayList<Customer>(); while (rs != null && rs.next()) { Customer a = new Customer(); a.setCustId(rs.getLong("CUST_ID")); a.setPerNo(period); a.setName(rs.getString("cust_nm")); data.add(a); }
Customer customer = new Customer("Will");
Customer customer = map.get(id); if(customer == null){ customer = new Customer(); customer.setId(id); customer.setName(rs.getString("CUSTOMER_NAME"));
for ( int i=0; i<100000; i++ ) { Customer customer = new Customer(.....); session.save(customer); if ( i % 20 == 0 ) { //20, same as the JDBC batch size //flush a batch of inserts and release memory: session.flush(); session.clear(); } }
@Controller @RequestMapping(value = "/users") public class UserController { @RequestMapping(params = "register") public String createForm(Model model) { model.addAttribute("user", new Customer()); return "user/register"; } }
@Controller public class UserController { @RequestMapping("/users/{register}") public String createForm(Model model) { model.addAttribute("user", new Customer()); return "user/register"; } }
public class Main { public static void main(String args[]) { String[] names = {"First", "Second", "Third"};//You Can Add More Names double[] amount = {20.0, 30.0, 40.0};//You Can Add More Amount List<Customer> customers = new ArrayList<Customer>(); int i = 0; while (i < names.length) { customers.add(new Customer(names[i], amount[i])); i++; } } }
List<Person> people = new ArrayList<Person>(); // Any class that extends person can be added people.add(new Customer()); people.add(new FieldEngineer()); for (Person person : people) { System.out.println(person); }
Customer customer = new Customer(); //set customer attributes JAXBContext jc = JAXBContext.newInstance(Customer.class); Marshaller marshaller = jc.createMarshaller(); StringWriter stringWriter = new StringWriter(); marshaller.marshal(customer, stringWriter ); log.info(stringWriter.toString());
List<Customer> customers = new ArrayList<Customer>(); ResultSet rs = stmt.executeQuery("SELECT * from CUSTOMER;"); while (rs.next()) { Customer customer = new Customer(); customer.setFirstName(rs.get("First_Name")); // ... and so on customers.add(customer); }
@GET @Produces(MediaType.APPLICATION_XML) @Path("/getCustomer") public Customer getCustomer() { Customer c = new Customer(); c.setName("Fred"); c.setEmail("fred@email.com"); c.setId(12345); return c; }