title: How does Hibernate work with normalized databases?
body: <p><strong>Preliminary Info</strong><br>
  I'm currently trying to integrate Hibernate with my team at work. We primarily do Java web development, creating webapps that provide data to clients. Our old approach involves calling stored procedures with JDBC (on top of Oracle boxes) and storing their results in beans. However, I've heard a lot about the benefits of integrating Hibernate into a development environment like ours so I'm attempting to move away from our old habits. Note: I'm using the Hibernate JPA annotation approach due to simplicity for team adoption's sake.<br>
  <strong>Specific Problem</strong><br>
  The specific issue I'm having currently is using Hibernate with normalized tables. We have a lot of schemas structured like so:</p>
  
  <pre><code>StateCodes (integer state_code, varchar state_name)
  Businesses (integer business_id, varchar business_name, integer state_code)
  </code></pre>
  
  <p>I want to be able to have a single @Entity that has all of the "Businesses" fields, except instead of "state_code" it has "state_name". To my understanding, Hibernate treats @Entity classes as tables. The @OneToMany, @OneToOne, @ManyToOne annotations create relationships between entities, but this is a very simplistic, dictionary-like lookup and I feel like it doesn't apply here (or might be overkill). </p>
  
  <p>One approach I've seen is  </p>
  
  <pre><code> @Formula("(select state_name from StateCodes where Businesses.state_code = state_code)")
   private String stateCode;
  </code></pre>
  
  <p>But, given Hibernate's perk of "avoiding writing raw SQL", this seems like bad practice. Not to mention, I'm <em>extremely</em> confused about how Hibernate will then treat this field. Does it get saved on a save operation? It's just defined as a query, not a column, after all.</p>
  
  <p>So what is the best way to accomplish this?</p>