title: Hibernate Unable to Create Unique Key Constraint
body: <p>I have an application which uses Hibernate to access database. It throws an error as like that:</p>
  
  <blockquote>
    <p>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [file:/C:/Program%20Files%20(x86)/XXX/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unable to create unique key constraint (column1, column2) on table TABLE: column1, column2 not found
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:273)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1125)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$400(Unknown Source)
        at java.awt.EventQueue$2.run(Unknown Source)
        at java.awt.EventQueue$2.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
    Caused by: org.hibernate.AnnotationException: Unable to create unique key constraint (column1, column2) on table TABLE: column1, column2 not found
        at org.hibernate.cfg.AnnotationConfiguration.buildUniqueKeyFromColumnNames(AnnotationConfiguration.java:616)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:348)
        at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1162)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:720)
        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
        ... 27 more</p>
  </blockquote>
  
  <p>I've checked this question: <a href="https://stackoverflow.com/questions/25183017/org-hibernate-annotationexception-unable-to-create-unique-key-constraint">org.hibernate.AnnotationException: Unable to create unique key constraint</a> and <a href="https://stackoverflow.com/questions/25221929/unable-to-create-unique-key-constraint">Unable to create unique key constraint</a> however they did not solve my problem.</p>
  
  <p>Is there any idea how to figure out the problem?</p>