title: Getting Hibernate mapping exception with java.util.list
body: <p>HI,
  I am getting a problem with a data member of a class. The data member is ContactNumbers. The ContactNumbers is a java.util.list and I am getting errors when hibernate maps the list in the database. What I want is that hibernate creates an array for the contactnumbers in the database postgresql. When I remove the variable contactnumbers of type list from BusinessUser class, the program runs correctly. Can someone helps??</p>
  
  <p>Here is my class:</p>
  
  <pre><code>public class User  
  {
      //other varibale contructors setters and getters
  }
  
  public class BusinessUser  extends Users implements IsSerializable
  {
      List &lt;String&gt; ContactNumbers;
      //other varibale contructors setters and getters
  }
  </code></pre>
  
  <p>My user mapping file is ok. 
  This is my business mapping file</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  &lt;!-- Generated Dec 2, 2010 4:42:45 AM by Hibernate Tools 3.4.0.Beta1 --&gt;
  &lt;hibernate-mapping&gt;
      &lt;joined-subclass name="com.BiddingSystem.Models.BusinessUser" extends="com.BiddingSystem.Models.Users" table="BUSINESSUSER" lazy="false"&gt;
          &lt;key&gt;
              &lt;column name="USERID" /&gt;
          &lt;/key&gt;
          &lt;property name="BusinessName" type="java.lang.String"&gt;
              &lt;column name="BUSINESSNAME" /&gt;
          &lt;/property&gt;
          &lt;property name="ContactPersonDetails" type="java.lang.String"&gt;
              &lt;column name="CONTACTPERSONDETAILS" /&gt;
          &lt;/property&gt;
          &lt;property name="FaxNumber" type="java.lang.String"&gt;
              &lt;column name="FAXNUMBER" /&gt;
          &lt;/property&gt;
          &lt;list name="ContactNumbers" inverse="false" table="BUSINESSUSER" lazy="true"&gt;
              &lt;key&gt;
                  &lt;column name="BUSINESSNAME" /&gt;
              &lt;/key&gt;
              &lt;list-index&gt;&lt;/list-index&gt;
              &lt;element type="java.lang.String"&gt;
                  &lt;column name="CONTACTNUMBERS" /&gt;
              &lt;/element&gt;
          &lt;/list&gt;
      &lt;/joined-subclass&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>I am getting this error:</p>
  
  <pre><code>Initial SessionFactory creation failed.org.hibernate.MappingException: Foreign key (FK6214B38B81858749:BUSINESSUSER [BUSINESSNAME])) must have same number of columns as the referenced primary key (BUSINESSUSER [BUSINESSNAME,idx])
  [WARN] /biddingsystem/System
  java.lang.ExceptionInInitializerError
      at com.BiddingSystem.server.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:18)
      at com.BiddingSystem.server.ServiceImpl.&lt;init&gt;(ServiceImpl.java:32)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at java.lang.Class.newInstance0(Class.java:355)
      at java.lang.Class.newInstance(Class.java:308)
      at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
      at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:324)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
  Caused by: org.hibernate.MappingException: Foreign key (FK6214B38B81858749:BUSINESSUSER [BUSINESSNAME])) must have same number of columns as the referenced primary key (BUSINESSUSER [BUSINESSNAME,idx])
      at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:113)
      at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:96)
      at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1354)
      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1261)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1377)
      at com.BiddingSystem.server.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:14)
      ... 26 more
  [WARN] Nested in java.lang.ExceptionInInitializerError:
  org.hibernate.MappingException: Foreign key (FK6214B38B81858749:BUSINESSUSER [BUSINESSNAME])) must have same number of columns as the referenced primary key (BUSINESSUSER [BUSINESSNAME,idx])
      at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:113)
      at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:96)
      at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1354)
      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1261)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1377)
      at com.BiddingSystem.server.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:14)
      at com.BiddingSystem.server.ServiceImpl.&lt;init&gt;(ServiceImpl.java:32)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at java.lang.Class.newInstance0(Class.java:355)
      at java.lang.Class.newInstance(Class.java:308)
      at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
      at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:463)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:324)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
  </code></pre>