Not 100% sure why, but heres two  possibilities:

(1) Does Feed implement equals() and hashode() correctly?
I actually forget if that affects the behaviour of a bag.

(2) Did you change an Item after saving the Subscription?
For a bag that would cause a delete then insert, instead of
an update (a list or map or array would cause an update).

Note also that <bag>s cannot add and remove elements
individually (this makes perfect sense when you consider
the semantics of a bag). So you could also try changing to
a Set. ( Then you definiately need a proper implementation
of equals() and hashCode() ).

What exactly was the code that caused the four SQL
statements?



                                                                                       
                                               
                    "Viktor Szathmary"                                                 
                                               
                    <[EMAIL PROTECTED]>                 To:     "Viktor Szathmary" 
<[EMAIL PROTECTED]>,                       
                    Sent by:                                 [EMAIL PROTECTED]         
                           
                    [EMAIL PROTECTED]       cc:                                        
                               
                    eforge.net                              Subject:     Re: 
[Hibernate] ... and how about bidirectional for a        
                                                             component? :)             
                                               
                                                                                       
                                               
                    29/01/03 04:57 PM                                                  
                                               
                                                                                       
                                               
                                                                                       
                                               




On Wed, 29 Jan 2003 00:34:01 -0500, "Viktor Szathmary"
<[EMAIL PROTECTED]> said:
> On Wed, 29 Jan 2003 00:06:38 -0500, "Viktor Szathmary"
> <[EMAIL PROTECTED]> said:
> > hi,
> >
> > to annoy people with more trivial questions: is it possible to have a
> > bidirectional one-to-many relationship between a component and a
> > firstclass object? i'm getting a MappingException: "An association
refers
> > to an unmapped class" (which is not entirely true, since it is in fact
> > mapped as a component of another class).
>
> i also considered mapping this as a nested component list inside the
> component, but for some reason i'm still getting MappingException: "No
> persister for: net.sf.flock.hibernate.Feed".

bah, i am indeed senile. believe me, this hurts me as much as it does
you... :) i left an old one-to-one reference in the mapping. that
explains the second MappingException ("No persiter..."). So, here's a
mapping that seems to work:

<hibernate-mapping>
           <class name="net.sf.flock.hibernate.Subscription" table
="subscription">
                     <id name="id" unsaved-value="null" length="32">
                               <generator class="vm.hex"/>
                     </id>
                     <component name="feed" class
="net.sf.flock.hibernate.Feed">
                               <parent name="subscription" class
="net.sf.flock.hibernate.Subscription"/>
                               <bag role="items" cascade="all">
                                          <key name="id" type="string">
                                                    <generator class
="vm.hex"/>
                                          </key>
                                          <composite-element class
="net.sf.flock.hibernate.Item">
                                                    <parent name="origin"
class="net.sf.flock.hibernate.Feed" column="feed_id"/>
                                          </composite-element>
                               </bag>
                     </component>
            </class>
</hibernate-mapping>

however, apparently this is less efficient than a regular one-to-many
was: even upon the first save(..) it generates:
INSERT INTO Subscription ...
INSERT INTO Item ...
DELETE FROM Item ...
INSERT INTO Item ...

so, there's an extra delete & insert... what could be the reason?

thx,
    viktor

ps. i promise in the future i'll spend more time thinking than posting..
:)

--
http://fastmail.fm - Choose from over 50 domains or use your own


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel




**********************************************************************
Any personal or sensitive information contained in this email and
attachments must be handled in accordance with the Victorian Information
Privacy Act 2000, the Health Records Act 2001 or the Privacy Act 1988
(Commonwealth), as applicable.

This email, including all attachments, is confidential.  If you are not the
intended recipient, you must not disclose, distribute, copy or use the
information contained in this email or attachments.  Any confidentiality or
privilege is not waived or lost because this email has been sent to you in
error.  If you have received it in error, please let us know by reply
email, delete it from your system and destroy any copies.
**********************************************************************





-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to