use of org.baeldung.querydsl.intro.entities.BlogPost in project tutorials by eugenp.
the class QueryDSLIntegrationTest method populateDatabase.
@BeforeClass
public static void populateDatabase() {
emf = Persistence.createEntityManagerFactory("org.baeldung.querydsl.intro");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
User user1 = new User();
user1.setLogin("David");
em.persist(user1);
User user2 = new User();
user2.setLogin("Ash");
em.persist(user2);
User user3 = new User();
user3.setLogin("Call");
em.persist(user3);
User user4 = new User();
user4.setLogin("Bishop");
em.persist(user4);
BlogPost blogPost1 = new BlogPost();
blogPost1.setTitle("Hello World!");
blogPost1.setUser(user1);
em.persist(blogPost1);
BlogPost blogPost2 = new BlogPost();
blogPost2.setTitle("My Second Post");
blogPost2.setUser(user1);
em.persist(blogPost2);
BlogPost blogPost3 = new BlogPost();
blogPost3.setTitle("Hello World!");
blogPost3.setUser(user3);
em.persist(blogPost3);
em.getTransaction().commit();
em.close();
}
Aggregations