-->
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.  [ 6 posts ] 
Author Message
 Post subject: Array one-to-many mapping - runtime error
PostPosted: Fri Mar 19, 2004 7:11 am 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
I obtain runtime error:
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:282)
at net.sf.hibernate.cfg.Configuration.addClass(Configuration.java:322)
... 7 more
Caused by: org.xml.sax.SAXParseException: The content of element type "array" must match "(meta*,(cache|jcs-cache)?,key,index,(element|one-to-many|many-to-many|composite-element|many-to-any))".


part of hbm.xml
Code:
        <joined-subclass
            name="com.domainmodel.InstrumentBondStatic"
            table="INSTRUMENT_BOND_TBL"
            dynamic-update="false"
            dynamic-insert="false"
            proxy="com.domainmodel.InstrumentBondStatic"
            >
            <key column="instrumentId"/>

            <array name="payments">
                <key column="instrumentId"/>
                <one-to-many class="com.domainmodel.InstrumentBondSpec"/>
            </array>

            <property
                name="issueRate"
                type="java.lang.Double"
                update="true"
                insert="true"
                column="issueRate"
                />

        </joined-subclass>


If
Quote:
array
is replaced with
Quote:
set
for example, everything works ok.


Top
 Profile  
 
 Post subject: additional
PostPosted: Fri Mar 19, 2004 7:14 am 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
If "array" is replaced with "set" for example, everything works ok.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 19, 2004 7:21 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You've forgot the index tag. An array is an indexed structure.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: array versus set
PostPosted: Mon Mar 22, 2004 5:45 am 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
It is originally "set", but I would like to change mapping to array only for one reason - method that returns this set is method exposed as WebService, so it must be array - to be known type of element.

So I don't know what should be @hibernate.collection-index column="????"
I don't have such field in existing db.


Code:
     * @hibernate.array cascade="all"
     * @hibernate.collection-key column="instrumentId"
     * @hibernate.collection-index column="????"
     * @hibernate.collection-one-to-many class="com.domainmodel.InstrumentBondPayments"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 22, 2004 5:52 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
it's the index of the collection, you can define it even if there is no index in db, try this for example:

* @hibernate.array cascade="all"
* @hibernate.collection-key column="instrumentId"
* @hibernate.collection-index column="instrumentId"
* @hibernate.collection-one-to-many class="com.domainmodel.InstrumentBondPayments"


Top
 Profile  
 
 Post subject: instrumentId is foreign key, not array index
PostPosted: Mon Mar 22, 2004 5:59 am 
Regular
Regular

Joined: Fri Nov 21, 2003 10:23 am
Posts: 81
instrumentId is primary key of master table (=base table) (=InstrumentBond) and also foreign key in detail table (=InstrumentBondPayment)

It does mean that to one instrumentId value corrensponds many records in InstrumentBondPayment table.

By my opinion instrumentId can't be collection index for array. I am wrong?


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

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.