131415161718192021222324252627
private EntityManager em; @Override public long createMilliTimeItem() { MilliTimeItem mti = new MilliTimeItem(); mti.setMilliTime(System.currentTimeMillis()); em.persist(mti); long result = mti.getID(); em.detach(mti); return result; }
19202122232425262728
private MyService myService; @Test public void testCreateAndRetrieve() { MilliTimeItem retr = myService.createAndRetrieve(); assertNotNull(retr); }
16171819202122
return "index"; } @RequestMapping(value="/getJSON", method = RequestMethod.GET) public @ResponseBody MilliTimeItem getJSON() { return new MilliTimeItem(System.currentTimeMillis()); }
2829303132333435363738
@Test public void testGetMilliTimeItem() { long id = myDAO.createMilliTimeItem(); MilliTimeItem retr = myDAO.getMilliTimeItem(id); assertNotNull(retr); assertEquals(id,retr.getID()); }
2223242526272829303132
} @RequestMapping(value = "/roundtrip") public String persistenceStatus(Model model) { MilliTimeItem retr = myService.createAndRetrieve(); model.addAttribute("RoundTrip", retr); return "roundtrip"; }
151617181920212223242526272829
@Override @Transactional public long createMilliTimeItem() { MilliTimeItem mti = new MilliTimeItem(); mti.setMilliTime(System.currentTimeMillis()); em.persist(mti); long result = mti.getID(); em.detach(mti); return result; }
2324252627282930313233
@RequestMapping(value = "/roundtrip") public String persistenceStatus(Model model) { long id = myService.create(); MilliTimeItem retr = myService.retrieve(id); model.addAttribute("RoundTrip", retr); return "roundtrip";