From: Andrea A. <aa...@li...> - 2002-10-10 13:25:24
|
Hi everybody, I have a little feature request/question for you. Suppose you have two beans Customer, Country, and Customer has a many-to-one property of type Country (not-null). In a long transaction I load all of the Countries to fill in a JCombobox in a form to input a new Customer. Then, when the user confirms the insertion, I open a new session and try to save the Customer, which has a reference to a Country loaded in the previous section... this will not work, because Hibernate nullifies the reference to the Country object unless I reload it in the new Session. What I wonder is, why this reloading work cannot be done by Hibernate itself? The nullifyTransientReferences method in SessionImpl walks thru the objects property and determines if the property is an Entity, then discards it if it's Transient... why cannot it have a look at the entity identifier, see if it's not null, and in that case load this object without the need of user's support? Of course this requires that the referenced entity has the "unsave-value" property set... What do you think? Best regards Andrea Aime |
From: Gavin K. <ga...@ap...> - 2002-10-10 15:10:34
|
An even better (and much easier to implement) approach might be to simply skip the nullification if the identifier of the transient instance indicates that it already exists on the database. Thats easy to implement. You wanna take a stab at it Andrea? Gavin ----- Original Message ----- From: "Andrea Aime" <aa...@li...> To: <hib...@li...> Sent: Thursday, October 10, 2002 11:31 PM Subject: [Hibernate] Long transactions, object update and many-to-one... > Hi everybody, > I have a little feature request/question for you. > Suppose you have two beans Customer, Country, and Customer > has a many-to-one property of type Country (not-null). In a long > transaction I load all of the Countries to fill in a JCombobox > in a form to input a new Customer. Then, when the user confirms > the insertion, I open a new session and try to save the Customer, > which has a reference to a Country loaded in the previous section... > this will not work, because Hibernate nullifies the reference > to the Country object unless I reload it in the new Session. > What I wonder is, why this reloading work cannot be done by > Hibernate itself? The nullifyTransientReferences method in SessionImpl > walks thru the objects property and determines if the property > is an Entity, then discards it if it's Transient... why cannot > it have a look at the entity identifier, see if it's not null, > and in that case load this object without the need of user's support? > Of course this requires that the referenced entity has the > "unsave-value" property set... > What do you think? > Best regards > Andrea Aime > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > hibernate-devel mailing list > hib...@li... > https://lists.sourceforge.net/lists/listinfo/hibernate-devel |
From: Andrea A. <aa...@li...> - 2002-10-10 15:27:58
|
Gavin King wrote: >An even better (and much easier to implement) approach might be to simply >skip the nullification if the identifier of the transient instance indicates >that it already exists on the database. > > Yep, it would be faster... >Thats easy to implement. You wanna take a stab at it Andrea? > Ok, I will try to make a patch and send it to you before the end of the week (it's a small patch it seems, but I have very few spare time). What's the ETA for hibernate 1.0.5? Andrea |
From: Gavin K. <ga...@ap...> - 2002-10-10 15:47:40
|
> Ok, I will try to make a patch and send it to you before the end of the > week (it's a small > patch it seems, but I have very few spare time). What's the ETA for > hibernate 1.0.5? 1.1.5 you mean.... I dunno. I have been debating this with myself. I had wanted to slow down on the file releases after 1.1.4 because I've been adding some major new features (including a new mapping DTD, the multi-table mappings stuff and the support for caching with JTA) so it would have made most sense for the next version to be called 1.2 beta. On the other hand, I sorta need to release a 1.1.5 because there is a bug that two people ran into in 1.1.4. Kinda obscure but still something that other people will trip up on. I guess we could branch CVS, but thats something to avoid if possible. The easiest thing to do would be a file release early next week, leaving the new mapping DTD and multitable mapping stuff undocumented. I just hope I havn't broken anything with the refactorings to queries + persisters. |