pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Java paste-bin - collaborative debugging tool View Help


Posted by Anonymous on Wed 7th Feb 17:03
download | new post

  1. EntityManagerFactory emf = Persistence.createEntityManagerFactory("gello");
  2.         EntityManager em = emf.createEntityManager();
  3.         EntityTransaction et = em.getTransaction();
  4.         et.begin();
  5.  
  6.         User user = (User) em.createNamedQuery("User.findByUserName").setParameter("username", "dan").getSingleResult();
  7.         System.out.println(user.getFirstName() + " " + user.getLastName());
  8.  
  9.         EmailAddress ea1 = new EmailAddress();
  10.         ea1.setUser(user);
  11.         ea1.setEmailAddressType(EmailAddressType.FIRST);
  12.         ea1.setValue("[email protected]");
  13.         user.getEmailAddresses().add(ea1);
  14.  
  15.         et.commit();
  16.  
  17.         //detached
  18.         user.getEmailAddresses().clear();
  19.  
  20.         EmailAddress ea2 = new EmailAddress();
  21.         ea2.setUser(user);
  22.         ea2.setEmailAddressType(EmailAddressType.SECOND);
  23.         ea2.setValue("[email protected]");
  24.         user.getEmailAddresses().add(ea2);
  25.  
  26.  
  27.         et = em.getTransaction();
  28.         et.begin();
  29.  
  30.         em.merge(user);
  31.  
  32.         printEmails(user);
  33.  
  34.         et.commit();
  35.         em.close();
  36.  
  37.         emf.close();

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@


Remember my settings