title: How to make a database table specifically for testing and create entitymanager based off that Spring-Boot
body: <p>So for examples I may have a real table, User</p>
  <pre class="lang-java prettyprint-override"><code>@Table('user')
  @Entity
  public class User(){
   @PrimaryId
   long id;
   String name;
   String email;
  ... etc. etc.
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>@Repository
  public class UserRepository extends CrudRepository{
   whatever repository methods
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>public class userRepositoryImpl{
   @PersistenceContext
   EntityManager em;
  
   public List&lt;User&gt; getUsersBasedOnCriteria(args){
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery&lt;User&gt; cr = cb.createQuery(User.class);
    Root&lt;User&gt; root = criteriaBuilder.getRoot();
    
    ... stuff based on criteria builder
  
    
    return res;
   }
  }
  </code></pre>
  <p>then I'd want something like TestUser that would be</p>
  <pre class="lang-java prettyprint-override"><code>@Table('testUser')
  
  public class TestUser{
  .......
  .......
  .......
  .......
  }
  </code></pre>
  <p>but when I am running tests I want to setup a test user table that will be used.  The methods that I have seen to do that seem like they would mock the entire database, all the models, etc. but I just want this one test table that has certain aspects of the user table.  So I want an in memory db but I want it to only use the mocked info.  I also want to be able to test userRepositoryImpl on a 'fake' userRepository class</p>
  <p>The reason I want to do this is because the current methods that I've seen be suggested did not work for my specific circumstance with how the database is set up and it makes more sense to me to use a fake table in this instance than fix whatever issue is preventing the current database from being set up in memory.  Excuse any errors in the snippets w/ how things are setup or annotations they are just examples I came up with for this question, not real code.</p>