title: hibernate update JPA foreign key
body: <p>My jpa looks like below</p>
  
  <pre><code>public class TESTClass implements Serializable {
  
      ...
  
      private String name;
  
      @EmbeddedId
      protected IssTESTPK issTESTPK;
  
      @ManyToOne(optional=false)
      @JoinColumns({
          @JoinColumn(name="DIVISION_CODE", referencedColumnName="DIVISION_CODE", nullable=false, insertable=false, updatable=false), 
          @JoinColumn(name="SURVEY_NUM", referencedColumnName="SURVEY_NUM", nullable=false, insertable=false, updatable=false)})
      private IssDivision issDivision;
  
  }
  </code></pre>
  
  <p>if i make change to 'name' and call merge, it able to update into database, but when i change issDivision, and call merge, it doesnt update database. how to solve this? </p>
  
  <p><BR>
  does it related to because i'm using embededId (composite primary keys) ?</p>
  
  <h2>updated</h2>
  
  <p>if i set upadted=true, i get below error</p>
  
  <pre><code>ERROR - ContextLoader.initWebApplicationContext(215) | Context initialization fa
  iled
  org.springframework.beans.factory.BeanCreationException: Error creating bean wit
  h name 'sessionFactory' defined in ServletContext resource [/WEB-INF/application
  Context.xml]: Invocation of init method failed; nested exception is org.hibernat
  e.MappingException: Repeated column in mapping for entity: com.compay.test.model
  .TESTClass column: SURVEY_NUM (should be mapped with insert="false" update="fa
  lse")
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory$1.run(AbstractAutowireCapableBeanFactory.java:409)
          at java.security.AccessController.doPrivileged(Native Method)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBean
  Factory.createBean(AbstractAutowireCapableBeanFactory.java:380)
          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
  ject(AbstractBeanFactory.java:264)
          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
  y.getSingleton(DefaultSingletonBeanRegistry.java:222)
          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
  an(AbstractBeanFactory.java:261)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
  (AbstractBeanFactory.java:185)
          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
  (AbstractBeanFactory.java:164)
          at org.springframework.beans.factory.support.DefaultListableBeanFactory.
  preInstantiateSingletons(DefaultListableBeanFactory.java:423)
          at org.springframework.context.support.AbstractApplicationContext.finish
  BeanFactoryInitialization(AbstractApplicationContext.java:728)
          at org.springframework.context.support.AbstractApplicationContext.refres
  h(AbstractApplicationContext.java:380)
          at org.springframework.web.context.ContextLoader.createWebApplicationCon
  text(ContextLoader.java:255)
          at org.springframework.web.context.ContextLoader.initWebApplicationConte
  xt(ContextLoader.java:199)
          at org.springframework.web.context.ContextLoaderListener.contextInitiali
  zed(ContextLoaderListener.java:45)
          at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
  t.java:3843)
          at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
  342)
          at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
  .java:791)
          at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
  1)
          at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
  
          at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.ja
  va:627)
          at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.j
  ava:553)
          at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488
  )
          at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
          at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
  :311)
          at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
  eSupport.java:117)
          at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
  
          at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
          at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
  
          at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443
  )
          at org.apache.catalina.core.StandardService.start(StandardService.java:5
  16)
          at org.apache.catalina.core.StandardServer.start(StandardServer.java:710
  )
          at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
  </code></pre>