title: How to find out if an email already exist with jpa spring and sending some error messag to the front end
body: <p>So i have a simple UsersDao</p>
  
  <pre><code>public interface UserDao extends JpaRepository&lt;User, Long&gt; {
  
  }
  </code></pre>
  
  <p>And inside my user controller i want to do something like this :</p>
  
  <pre><code>@RequestMapping(value = "/register",method = RequestMethod.POST)
  public void addUser(@RequestBody User user) {
  
      //How do i check if user already exist with email instead of id
      // i managed to do this but can i search on something else than the id
      User user1 = userDao.findOne(1);
  
      if (user.getEmail().equals(user1.getEmail()))
      {
  
          // And how should i give one error to the front end if the email 
         //already exist I'm using angular js
  
      }
      else {
  
          userDao.save(user);
  
      }
  
  }
  </code></pre>
  
  <p>I also have some extra questions on this topic:</p>
  
  <p>Somethings that are not clear are following. I have done a small tutorial on jpa but there they use: </p>
  
  <p>EntityManager,
  EntityTransaction</p>
  
  <p>Note : when using EntityManagerFactory  it goes as follow :</p>
  
  <pre><code>    EntityManagerFactory emf = null,
  
      //Then they use EntityManagerFactory
  
          emf = Persistence.createEntityManagerFactory("SomeValue")
      //where can i get "someValue" When using application .properties 
  
  //because in the example they use xml but can't find the right properties in application.properties
  </code></pre>
  
  <p>Or do i not need to use these in springboot</p>
  
  <p>Sorry for all these question. I really want to get into spring but somethings are still a bit unclear at this point ;)</p>