title: How to solve duplicate column name exception in @OneToMany relationship
body: <p>I am trying to @JoinColumn two entities, named Customer and Account. One customer can have multiple accounts, so I thought it was right to use @OneToMany in Customer entity. and @ManyToOne in Account entity. However, it keeps giving me the Duplicate column name in the console. 
  It can be solved by changing the variable name, but I cannot simply change it, because hibernate will not find the column name in the DB. Even adding @Column name attribute won't work.</p>
  
  <p>Is there any way to solve this problem?</p>
  
  <p>I have tried following:</p>
  
  <ul>
  <li>change the owner entity. I put @JoinColumn in Account entity instead &lt;- not working</li>
  <li>change the variable name. &lt;- create another error SQL Error: 904, SQLState: 42000</li>
  <li>try with @OneToOne instead. &lt;- it worked, but since multiple account number retrieved, then result set cannot be mapped</li>
  <li>follow the right way as in example, but duplicate mapping exception is not solved.</li>
  <li>change the @Id position. &lt;- it works but its not what I expected.</li>
  </ul>
  
  <p>I have tried the SQL query in DB. The query is work, but I have no idea how to map it in hibernate jpa.</p>
  
  <p>Oracle Query</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT a.USR_ID, a.USR_MGNT_NO, a.CUST_NO, a.ACCT_STATUS,
          b.ACCT_SEQ, b.ACCT_NO, b.CUST_NO, b.CUST_NM, b.SBJ_CD, b.ACCT_PRD_NM
  FROM LB_USR_BASE a LEFT OUTER JOIN
   LB_ACCT_BASE b ON
  a.CUST_NO=b.CUST_NO
  WHERE a.USR_MGNT_NO=:usrMgtNo;
  </code></pre>
  
  <p>Customer Entity</p>
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  @Table(name = "CUSTOMER")
  @Data
  @Builder
  @AllArgsConstructor
  @NoArgsConstructor
  
  public class Customer implements Serializable{
  
  
      private static final long serialVersionUID = 1L;
  
      @Id
      private String custNo;
  
      private String usrId;
      private String usrMgntNo;
      private String acctStatus;
  
      @OneToMany(cascade = CascadeType.ALL, mappedBy = "user")
      @JoinColumn(name = "custNo")
      private Set&lt;Account&gt; accounts = new HashSet&lt;Account&gt;();
  
  
  }
  </code></pre>
  
  <p>Account Entity</p>
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  @Table(name = "ACCOUNT")
  @Data
  @Builder
  @AllArgsConstructor
  @NoArgsConstructor
  public class Account {
      @Id
      private String acctId;
      private String acctNo;
  
      @ManyToOne
      private UsrBase user;
      private String sbjCd;
      private String custNo;
  
  }
  </code></pre>
  
  <p>Repository</p>
  
  <pre class="lang-java prettyprint-override"><code>public interface CustAcctRepository extends JpaRepository&lt;Customer, String&gt;{
  
      List&lt;Customer&gt; findAcctByUsrMgntNo(String usrMgntNo);
  
  }
  </code></pre>
  
  <p>Service/ Controller</p>
  
  <pre class="lang-java prettyprint-override"><code>List&lt;Customer&gt; tes = CustAcctRepo.findAcctByUsrMgntNo("12345"));
  </code></pre>
  
  <pre><code>Caused by: org.hibernate.DuplicateMappingException: Table [ACCOUNT] contains physical column name [cust_no] referred to by multiple physical column names: [cust_no], [custNo]
  </code></pre>
  
  <p>==========</p>
  
  <h1><strong>EDIT:</strong></h1>
  
  <p>I modified both entities, as follow:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Account {
      @Id
      private String acctSeq;
      private String acctNo;
  
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "custNo",insertable = false, updatable = false)
      private UsrBase user;
  
  }
  </code></pre>
  
  <p>and</p>
  
  <pre class="lang-java prettyprint-override"><code>public class Customer implements Serializable{
  
  
      private static final long serialVersionUID = 1L;
  
      @Id
      private String custNo;
  
      private String usrId;
      private String usrMgntNo;
      private String acctStatus;
  
      @OneToMany(cascade = CascadeType.ALL)
      private Set&lt;AcctBase&gt; accounts = new HashSet&lt;AcctBase&gt;();
  
  
  }
  </code></pre>