title: Map one value to multiple columns in JPA
body: <p>I get an input value from the user and store it into the DB.
  I use JPA to write into DB.
  If I need to store the input value into 2 columns in the DB, what is the annotation I must use?</p>
  
  <p>Code below. </p>
  
  <p><strong><em>I need to store user input - (stored in Bean field UserOrderDetails.noOfItemsSelected) into 2 columns in the DB table NoOfItemsSelected and NoOfItemsDispatched.
  What annotation should I use?</em></strong></p>
  
  <p>The catch is that I do not want to add a field for NoOfItemsDispatched in the Entity Bean.</p>
  
  <p>DB Table:</p>
  
  <pre><code>create table UserOrderDetails(
  TransactionId varchar(255),
  CreationDateTime datetime2(),
  NoOfItemsSelected int,
  NoOfItemsDispatched int
  )
  GO
  </code></pre>
  
  <p>My Entity Bean:</p>
  
  <pre><code>@Entity
  @Table(name="UserOrderDetails")
  public class UserOrderDetails {
  
      @Id
      private String transactionId;   
      private Timestamp CreationDateTime; 
      private int noOfItemsSelected;
      //Getters and Setters
  }
  </code></pre>
  
  <p>Controller class for Reference:</p>
  
  <pre><code>class UserOrderCreationController {
  @RequestMapping(value = "/createUserOrder", method = RequestMethod.POST)
      public ResponseEntity&lt;?&gt; createUserOrder(@RequestBody UserOrderDetails userOrderDetails , @RequestHeader HttpHeaders headers) throws Exception{
  
      //Some business logic to handle the user Order
  
      dbrepository.save(UserOrderDetails);
  
      return new ResponseEntity&lt;UserOrderDetails&gt;(userOrderDetails, HttpStatus.CREATED);
      }
  }
  </code></pre>
  
  <p>Thanks</p>