title: Unit testing by mocking the data layer or using embedded database
body: <p>For unit testing is it better to mock the data layer or use an embedded database like derby?</p>
  
  <p>I know that it also depends on the purpose of the testing. But if I go with derby I don't have to mock all the objects and I assume that would be easier. On the other hand I understand that that is more towards integration testing. So which one is more common for unit testing?</p>
  
  <p>Thanks.</p>
  
  <p>Update according to comments: </p>
  
  <p>So I have derby configured now but my manager insists on using easymock. We are using jpa and we have about 20 tables => data models. So then for each method like for project model should I specify the return type of the mockedProject for all its methods? Like getProjectName(), getProjectId(), etc? And also should I mock the persistent manager object. I thought that is just a lot in comparison with just configuring an embeded db like derby. </p>