I am using Hibernate 4 with Spring 3, and when I try to run the Junit test, the values ββare not stored in the database
In my DAO implementation class
@Transactional @Repository public class ProjectDAOImpl extends GenericDAOImpl<Project> implements ProjectDAO { public void create(Project project) { entityManager.persist(project); System.out.println("val 2 -- "+project.getProjectNo()); } @PersistenceContext public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; }
and in the Junit test I have
@TransactionConfiguration @ContextConfiguration({"classpath:applicationContext.xml"}) @Transactional @RunWith(SpringJUnit4ClassRunner.class) public class ProjectTest { @Resource ProjectService projectService; @Test public void createProject(){ Project project = new Project(); project.setProjectName("999---"); projectService.create(project); }
I can see the value for this statement in the console, although the record is not saved in the database.
System.out.println("val 2 -- "+project.getProjectNo());
How can I solve this problem?
source share