title: Hibrernate: Attribute "type" must be declared for element type "column"
body: <p>I am trying to save to two tables in SQL server using Hibernate:
  ORDER and ORDER_ITEM
  I get an error:
  Attribute "type" must be declared for element type "column".
  Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Unable to read XML.</p>
  
  <p>This produces a NullPointerException</p>
  
  <p>If I understand correctly, this means that when I try to save to the order_item table, the getter for the foreign key is empty, but how would I set it if is designed to 'Autoincrement', I thought that hibernate would handle this in it's transaction.</p>
  
  <p>Below are my POJO's and Hibernate mappings. I have omitted the getters and setters from this copy/paste, but they are present in my actual code</p>
  
  <p>I am also successful in saving just to the ORDER table if I remove the set</p>
  
  <p>Order.java:</p>
  
  <pre><code>public class Order {
  public Order(){
      super();       
  }
  
  private int orderId;        
  private Set&lt;LineItem&gt; items;         
  private String strPhone;          
  private String strEmail;    
  private String strFirstName;   
  private String strLastName;  
  private String strParentFirstName;    
  private String strParentLastName;    
  private String strOrganizationName;    
  private String strOrganizationType;         
  private String strComment;         
  </code></pre>
  
  <p>} </p>
  
  <p>order.hbm.xml:</p>
  
  <pre><code>&lt;hibernate-mapping&gt;
  &lt;class name="dbobjects.Order" table="orders"&gt;     
  
      &lt;id name="orderId" type="integer" column="order_id"&gt;
          &lt;generator class="increment"/&gt;
      &lt;/id&gt;
  
      &lt;property name="strPhone"            type="string" column="phone_number"/&gt;
      &lt;property name="strFirstName"        type="string" column="first_name"/&gt;
      &lt;property name="strLastName"         type="string" column="last_name"/&gt;
      &lt;property name="strParentFirstName"  type="string" column="parent_first_name"/&gt;
      &lt;property name="strParentLastName"   type="string" column="parent_last_name"/&gt;
      &lt;property name="strOrganizationName" type="string" column="organization_name"/&gt;
      &lt;property name="strOrganizationType" type="string" column="organization_type"/&gt;        
      &lt;property name="strComment"          type="string" column="comments"/&gt;
  
      &lt;set name="items" table="order_item" fetch="select" cascade="all"&gt;
          &lt;key&gt;
              &lt;column name="orderId" type="java.lang.Integer"/&gt;                
          &lt;/key&gt;
          &lt;one-to-many class="dbobjects.LineItem"/&gt;
      &lt;/set&gt;
  
  &lt;/class&gt;    
  </code></pre>
  
  <p></p>
  
  <p>LineItem.java:</p>
  
  <pre><code>public class LineItem {
  
  public LineItem(){
      super();
  }
  
  private int orderItemId;//this will be the primary key
  private int orderId;//this is the foreign key to the order 
  private String age;    
  private String gender;    
  private String type;
  private String itemSize;        
  private int itemQuantity;
  </code></pre>
  
  <p>}</p>
  
  <p>lineItem.hbm.xml:</p>
  
  <p>
    </p>
  
  <pre><code>&lt;id column="order_item_id" name="orderItemId" type="integer"&gt;
    &lt;generator class="increment"/&gt;
  &lt;/id&gt;
  
  &lt;property column="age" name="age" type="string"/&gt;
  &lt;property column="gender" name="gender" type="string"/&gt;
  &lt;property column="quantity" name="itemQuantity" type="integer"/&gt;
  &lt;property column="size" name="itemSize" type="string"/&gt;
  &lt;property column="clothing_type" name="clothingType" type="string"/&gt;
  
  &lt;many-to-one name="orderId" class="dbobjects.Order" fetch="select" column="order_id" type="java.lang.Integer"/&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>This is where the error is thrown when I Instanciate the session:</p>
  
  <pre><code>**session = HibernateUtil.getSessionFactory().openSession();**←
          try{        
          session.beginTransaction();
          session.save(order);
          session.getTransaction().commit();
  </code></pre>
  
  <p>So the question is: How do I handle this situation with 'autoincrement' primary key that is not accessible to another table as a foreign key</p>