public static StaticAuction auction3() { StaticAuction auction = new StaticAuction(); auction.setDescription("Auction 3"); auction.setImage("auction3.jpg"); auction.setName("A3"); auction.setStartPrice(1010); return auction; }
public static StaticAuction auction2() { StaticAuction auction = new StaticAuction(); auction.setDescription("Auction 2"); auction.setImage("auction2.jpg"); auction.setName("A2"); auction.setStartPrice(1000); return auction; }
public static void populateDB(EntityManagerFactory emf) { EntityManager em = emf.createEntityManager(); em.getTransaction().begin(); StaticUser user1 = user1(); em.persist(user1); StaticAddress address1 = address1(); em.persist(address1); user1.setAddress(address1); StaticUser user2 = user2(); em.persist(user2); StaticUser user3 = user3(); em.persist(user3); StaticAuction auction1 = auction1(); em.persist(auction1); StaticAuction auction2 = auction1(); em.persist(auction2); StaticAuction auction3 = auction1(); em.persist(auction3); StaticBid bid1 = new StaticBid(); bid1.setAmount(110); bid1.setTime(System.currentTimeMillis()); bid1.setAuction(auction1); bid1.setUser(user1); em.persist(bid1); StaticBid bid2 = new StaticBid(); bid2.setAmount(111); bid2.setTime(System.currentTimeMillis()); bid2.setAuction(auction1); bid2.setUser(user2); em.persist(bid2); StaticBid bid3 = new StaticBid(); bid3.setAmount(1100); bid3.setTime(System.currentTimeMillis()); bid3.setAuction(auction2); bid3.setUser(user2); em.persist(bid3); em.getTransaction().commit(); USER1_ID = user1.getId(); USER2_ID = user2.getId(); USER3_ID = user3.getId(); AUCTION1_ID = auction1.getId(); AUCTION2_ID = auction2.getId(); AUCTION3_ID = auction3.getId(); BID1_ID = bid1.getId(); BID2_ID = bid2.getId(); BID3_ID = bid3.getId(); ADDRESS1_ID = address1.getId(); }