-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: could not initialize collection
PostPosted: Thu Sep 16, 2004 4:15 pm 
Newbie

Joined: Fri Jul 02, 2004 9:05 pm
Posts: 10
I am getting exception "could not initialize collection" after a criteria query that looks like it is working correctly. I suspect it has something to do with the inclusion of an "extra" field in an association table in a composite-element, as I'm not sure what kinds of objects are being stored my "java.util.Set" (I'm hoping StatementItem objects).

Hibernate version: 2.1.6

Mapping documents: (minimalized)

Code:

  StatementOject.hbm.xml:
    <class
        name="gov.alaska.ezdoc.StatementObject"
        table="statements"
        dynamic-update="false"
        dynamic-insert="false">

        <id
            name="id"
            column="id"
            type="java.lang.String">
            <generator class="assigned"/>
        </id>

         <set name="itemList" table="statement_items" lazy="false">
          <key column="statementId"/>
          <composite-element class="gov.alaska.ezdoc.StatementItem">
                   <property name="value" type="java.lang.String" not-null="false"/>
             <many-to-one name="item" column="item_id" class="gov.alaska.ezdoc.Item" cascade="none"/>
            </composite-element>
        </set>
    </class>

  Item.hbm.xml:
    <class
        name="gov.alaska.ezdoc.Item"
        table="items"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="itemId"
            column="item_id"
            type="java.lang.String"
            unsaved-value=""
        >
            <generator class="assigned">
            </generator>
        </id>

       <property
            name="itemName"
            type="java.lang.String"
            update="true"
            insert="true"
            column="item_name"
        />
    </class>

  StatementItem.hbm.xml:
    <class
        name="gov.alaska.ezdoc.StatementItem"
        table="statement_items"
        dynamic-update="false"
        dynamic-insert="false">

        <composite-id>
            <key-property name="statementId" column="statement_id"/>
            <key-property name="itemId" column="itemId"/>
        </composite-id>
       
       <property
            name="value"
            type="java.lang.String"
            update="true"
            insert="true"
            column="value"/>

        <many-to-one name="item" column="item_id" insert="false" update="false" cascade="none" not-null="true"/>
                   
    </class>



Full stack trace of any exception that occurs:

Code:
[java] StatementMaker.list() HibernateException: net.sf.hibernate.JDBCException: could not initialize collection: [gov.alaska.ezdoc.StatementObject.itemList#63487693]


Name and version of the database you are using: MySQL 5.0.0-alpha-standard

The generated SQL (show_sql=true):

Code:

     [java] Hibernate: select this.id as id0_, this.created as created0_, this.shares as shares0_, this.modified as modified0_, this.owner as owner0_, this.status as status0_, this.type as type0_, this.role as role0_ from statements this where 1=1 order by this.id asc

     [java] Hibernate: select itemlist0_.statementId as statemen1___, itemlist0_.value as value__, itemlist0_.item_id as item_id__, item1_.item_id as item_id0_, item1_.item_name as item_name0_, item1_.data_type as data_type0_, item1_.description as descript4_0_, item1_.statement_type as statemen5_0_, item1_.seq_num as seq_num0_ from statement_items itemlist0_ left outer join items item1_ on itemlist0_.item_id=item1_.item_id where itemlist0_.statementId=?



Debug level Hibernate log excerpt: not available

Java code between sessionFactory.openSession() and session.close():

Code:
criteria = session.createCriteria(StatementObject.class);
criteria.addOrder(net.sf.hibernate.expression.Order.asc("id"));
if (id.length()>0) criteria.add(Expression.eq("id",id));
this.statementList = criteria.list();
this.statementCount = this.statementList.size();
this.iterator = this.statementList.iterator();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.