Package org.jpa

Examples of org.jpa.News


  @Test
  public void testPersistUpdateDeleteNews() {
    String titluTest="Titlunewstest";
    String continut="ContinutContinutContinutContinutContinutContinutContinutContinut";
    Date dataTest=new Date();
    News n=new News();
    News nT=new News();
    n.setContinut(continut);
    n.setDataAparitiei(dataTest);
    n.setTitlu(titluTest);
     EntityManager em = emf.createEntityManager();
       em.getTransaction().begin();
       em.persist(n);
       em.getTransaction().commit();
       nT=(News) em.createQuery("Select n from News n where n.titlu=:titluTest").setParameter("titluTest", titluTest).getSingleResult();
       assertTrue(nT.getTitlu()==n.getTitlu());
       em.getTransaction().begin();
       nT.setTitlu(titluTest+"Update");
       em.getTransaction().commit();
       n=(News) em.createQuery("Select n from News n where n.titlu=:titluTest").setParameter("titluTest", titluTest+"Update").getSingleResult();
       assertEquals(titluTest+"Update",n.getTitlu());
       em.getTransaction().begin();
       nT=em.find(News.class, n.getIdNews());
View Full Code Here

TOP

Related Classes of org.jpa.News

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.