title: How can i get a value generated by trigger (before insert) when i save an item?
body: <p>o/</p>
  
  <p>I'm using Spring Boot on Gradle w/ JPA</p>
  
  <p>I have the follow object: <code>{"id":123,"year":"123","name":"Xxxx","userKey": XXXXX}</code></p>
  
  <p>I will POST just "name" and "year" and the MySQL Trigger will generate the "userKey" BEFORE insert the data.</p>
  
  <p>When i call <code>rep.saveAndFlush(object)</code> i will return the new object to the user WITH the userKey. </p>
  
  <p>But its not happening! :/
  When i send the POST <code>{ "name" : "Teste" , "year" : 30}</code>
  The System returns <code>{"id":37,"year":"30","name":"Teste","userKey":null}</code></p>
  
  <p>If i try to get passing the ID as parameter, it returns <code>{"id":37,"year":"30","name":"Teste","userKey":"VVUR"}</code></p>
  
  <p>Why??</p>
  
  <p>How can i return the object with your complete data??</p>
  
  <p>I tried:</p>
  
  <pre><code>testeRepository.saveAndFlush(teste);
  return new ResponseEntity&lt;&gt; (teste, HttpStatus.CREATED);
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>testeRepository.saveAndFlush(teste);
  testeRepository.flush(teste);
  return new ResponseEntity&lt;&gt; (teste, HttpStatus.CREATED);
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>testeRepository.saveAndFlush(teste);
  testeRepository.flush(teste);
  teste = testeRepository.findOne(teste.getId()); /* Same as GET */
  return new ResponseEntity&lt;&gt; (teste, HttpStatus.CREATED);
  </code></pre>
  
  <p>So.. isnt working yet! :( Just returns the ID and Null on userKey!</p>