How recently did you try LongMappedForeignMapper? It's been updated recently. In any case, if you attach the test project I will try to look at it, but it may help to clarify: what is the sequence of events of saving user / saving address / setting value of user.address? The problem is that the address doesn't have its id until it's saved, which means there's nothing for user.address to reference. That is why I wrote LongMappedForeignMapper and recently added a beforeSave lifecycle event, so you just call its apply -- user.address(address) -- and it will update its Long value before its saved.
------------------------------------- george<geo...@mattandgeorge.com> wrote: What I want to do: Create a one-to-zero-or-one relationship between User and Address. I.e. User belongs to Address. When a new user signs up for an account they need to fill in an address form at that same time. So the user.address object needs to be initialised properly when the user object is created. (this part is working ok). I also want (for backwards compatibility) existing users to get a new Address object when they update their profile if they currently don't have an address. I.e. in the users table the address foreign key is null. (this part nearly works) What the problem is: When a new user signs up it seems to work fine. The address is saved in the database and the foreign key is set on the user. However, when there is an existing user with no address (the user.address FK is NULL), they fill in the form and click update. The address is saved into the database, BUT the user.address FK is not set in the users table. It remains NULL. I have tried various combinations of things such as primeObj(), apply () and LongMappedForeignMapper, but I don't understand why the FK is not being updated. Here is my User.scala http://gist.github.com/169639 and my Address.scala http://gist.github.com/169638 I also have a hello-lift app that demonstrates this problem if it's useful. Thanks in advance! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---