hi,

i found out more after playing around for a littlebit... it turns out one
of the properties in Bar is a java.util.Date... if i remove that property
from the mapping, everything's cool, it does 2 inserts as expected..
however, with the Date there, i believe an equality check fails (i assume
hibernate internally represents it as a java.sql.Timestamp so the
comparison is screwed)...

so, what do you suggest? should i represent dates as
java.sql.Date/Timestamp? it's kinda counterintuitive, that using a
java.util.Date would cause extraneous updates... perhaps hibernate could
store a java.util.Date internally for doing the comparison with the
original property, and only convert it to Timestamp at the last moment
for the query...

..or perhaps i'm totally wrong about all this? :)

best regards,
  viktor

On Mon, 13 Jan 2003 16:29:54 +1100 (EST), "Gavin King" <[EMAIL PROTECTED]>
said:
> 
> On the remote chance that there was actually a bug in this,
> I took your mapping document, ported it to the 1.0 mapping
> DTD, ran CodeGenerator to produce the persistent classes,
> ran your code against Hibernate2. I did not observe the
> behaviour you report (exactly two insert statements).
> 
> I suggest that you re-check your code, since as I said
> in my last mail, this is not how Hibernate behaves.
> 
> Especially check to make sure that the save() call does not
> somehow change the state of your objects. (eg. setId() alters
> the state or something strange like that.)
> 
> I suggest you use CodeGenerator to do the same thing I did....
> 
> Gavin
> 
> 
> > On Sun, 12 Jan 2003 17:32:16 +1100 (EST), "Gavin King"
> > <[EMAIL PROTECTED]> said:
> >> > am i doing something wrong or this is a known limitation?
> >>
> >> You must be doing something wrong (though I'm not quite sure
> >> what). A bidirectional one-to-many association with
> >> readonly="true" should require only 1 SQL statement per
> >> element.
> >>
> >>
> >> Are you sure that you aren't
> >>
> >> (a) flushing the Session between saving the children and adding
> >> them to the collections
> >>
> >> (b) missing the readonly attribute of the collection mapping
> >
> > here's how the mapping looks like:
> >
> >     <class name="Foo" table="foo">
> >             <id name="id">
> >                     <generator class="vm.hex"/>
> >             </id>
> >             <property name="title"/>
> >             <bag role="items"  readonly="true" cascade="all">
> >                     <key column="foo_id"/>
> >                     <one-to-many class="Bar"/>
> >             </bag>
> >      </class>
> >
> >     <class name="Bar" table="bar">
> >             <id name="id">
> >                     <generator class="vm.hex"/>
> >             </id>
> >             <many-to-one name="origin" class="Foo" column="foo_id"/>
> >             <property name="title"/>
> >     </class>
> >
> > the save code is really simple:
> >
> >         // ... set up Foo foo, with 1 Bar child, child has parent set as
> > origin
> >
> >     Session s = this.sessionFactory.openSession();
> >     s.save(foo);
> >     s.flush();
> >     s.connection().commit();
> >     s.close();
> >
> >
> > what is the problem with the above? i would like to understand the logic
> > that makes hibernate do an extra UPDATE...
> >
> > thx,
> >
> >    viktor
> > --
> >
> >   [EMAIL PROTECTED]
> >
> > --
> > http://fastmail.fm - A fast, anti-spam email service.
> 
> 
> 
> 
-- 
  
  [EMAIL PROTECTED]

-- 
http://fastmail.fm - The professional email service


-------------------------------------------------------
This SF.NET email is sponsored by: Take your first step towards giving 
your online business a competitive advantage. Test-drive a Thawte SSL 
certificate - our easy online guide will show you how. Click here to get 
started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to