title: Hibernate syntax error: Attribute "column" must be declared for element type "column"
body: <p>I'm an experienced Java-developer but have just started using Hibernate am doing something (probably multiple things) wrong in my class-xml. Here is the xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; 
  &lt;!DOCTYPE hibernate-mapping PUBLIC 
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  
  &lt;hibernate-mapping&gt; 
  &lt;class name="database.entities.LineItem" table="algorithms_in_production"&gt; 
  &lt;composite-id&gt;
      &lt;key-many-to-one name="algorithm" class="database.entities.Algorithm"  column="algorithm_id" /&gt;
      &lt;key-many-to-one name="instrument" class="database.entities.Instrument" column="instrument_id" &gt; &lt;/key-many-to-one&gt;
      &lt;key-many-to-one name="underlyings" class="database.entities.Underlyings" column="underlyings_id" &gt; &lt;/key-many-to-one&gt;
      &lt;key-many-to-one name="setting" class="database.entities.AlgorithmSetting" column="setting_id" &gt; &lt;/key-many-to-one&gt;
  &lt;/composite-id&gt;
  
  &lt;many-to-one name="algorithmStatistic" class="Algorithm" fetch="join" unique="true" /&gt;
  
  &lt;property name="dateInProduction" column="date_in_production" type="org.joda.time.contrib.hibernate.PersistentDateTime"/&gt; 
  &lt;property name="dateOutProduction" column="date_out_production" type="org.joda.time.contrib.hibernate.PersistentDateTime"/&gt; 
  
  &lt;/class&gt; 
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>And this is the xml for the Algorithm-class:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; 
  &lt;!DOCTYPE hibernate-mapping PUBLIC 
  "-//Hibernate/Hibernate Mapping DTD//EN" 
  "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"&gt; 
  
  &lt;hibernate-mapping&gt; 
  &lt;class name="database.entities.Algorithm" table="algorithms"&gt; 
  &lt;id name="algorithmId" type="int" column="algorithm_id"&gt; 
      &lt;generator class="native"/&gt; 
  &lt;/id&gt; 
  
  &lt;property name="algorithmTypeId" column="algorithm_type_id" type="int"/&gt; 
  &lt;property name="name" column="name" type="String"/&gt; 
  
  &lt;/class&gt; &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>And this is the relevant part of the classes:</p>
  
  <pre><code>public class LineItem {
      private Algorithm algorithm;
      private Instrument instrument;
      private Underlyings underlyings;
      private AlgorithmSetting setting;
      private AlgorithmStatistic algorithmStatistic;
      List&lt;AlgorithmReturn&gt; algorithmReturns;
      private DateTime dateInProduction;
      private DateTime dateOutProduction;
  ...
  
  
  public class Algorithm {
  private int algorithmId;
  @SuppressWarnings("unused")
  private int algorithmTypeId;
  private String name;
  ...
  </code></pre>
  
  <p>And here is the table that I'm mapping the LineItem-class to:</p>
  
  <pre><code>`Table "public.algorithms_in_production"
  Column              |            Type             | Modifiers
  ---------------------+-----------------------------+-----------
  algorithm_id        | integer                     | not null
  instrument_id       | integer                     | not null
  underlyings_id      | integer                     | not null
  setting_id          | integer                     | not null
  date_in_production  | timestamp without time zone | not null
  date_out_production | timestamp without time zone |
  "pk_algorithms_in_production" PRIMARY KEY, btree (algorithm_id, instrument_id, underlyings_id, setting_id)`
  </code></pre>
  
  <ul>
  <li>Algorithm is a class that is mapped uniquely to algorithm_id. </li>
  <li>Instrument is a class that is mapped uniquely to instrument_id. </li>
  <li>Underlyings is a class that is mapped uniquely to underlyings_id. </li>
  <li>AlgorithmSetting is a class that is mapped uniquely to setting_id. </li>
  <li>AlgorithmStatistic is a class that is mapped uniquely to the primary key in the table above.</li>
  <li>AlgorithmReturn is a class that is mapped uniquely to the primary key in the table above plus a timestamp. The list should hold all the instances that maps to the primary key. </li>
  </ul>
  
  <p>Here is the stackstrace:</p>
  
  <pre><code>SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
  SLF4J: Defaulting to no-operation (NOP) logger implementation
  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  Initial SessionFactory creation failed.org.hibernate.MappingException: An association from the table algorithms_in_production refers to an unmapped class: Algorithm
  Exception in thread "main" java.lang.ExceptionInInitializerError
      at taipan.database.helpers.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:23)
      at taipan.database.aggregators.LineItemsInProduction.getLineItems(LineItemsInProduction.java:77)
      at taipan.main.BacktestingFictive.main(BacktestingFictive.java:75)
  Caused by: org.hibernate.MappingException: An association from the table algorithms_in_production refers to an unmapped class: Algorithm
      at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1824)
      at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1756)
      at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1423)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
      at taipan.database.helpers.HibernateUtil.&lt;clinit&gt;(HibernateUtil.java:19)
      ... 2 more
  </code></pre>
  
  <p>Thanks in advance for the help!</p>