On Wed, Jan 6, 2010 at 12:15 PM, Julian Backes <[email protected]>wrote:
> Thanks for your answer!! > > > You can use mapper by itself. There's a dependency on lift webkit I >> believe. There might be some other issues, as i don't if anyone is >> using it that way. >> > This is perfectly working > > > As for the number, are you talking about a userId? Why would you think >> you can't set an arbitrary field in Mapper? >> > no, it is not a userId, just think of it as some string. Let's call it > userSpecialString for the moment. I know that I can set some field but my > problem is that when *storing a new user in the database*, the system > should: > > 1) start transaction > 2) generate special number/string from database > 3) set userSpecialString to this generated thing > 4) store new user in the database > 5) end transaction > In this previous question: http://old.nabble.com/%28Newbie-Question%29-How-to-do-simple-transaction-with-mapper--td26191398.html I find the following: import net.liftweb.*mapper*.{DB, DefaultConnectionIdentifier} DB.use(DefaultConnectionIdentifier) { conn => conn.setAutoCommit(false) ... // CRUDs if(success) conn.commit else conn.rollback conn.setAutoCommit(true) } Have you tried something like this? > Steps 2-4 are no problem. My problem is how to do this in one transaction > (steps 1 and 5) and where the best place is so that steps 1-5 automatically > happen when calling newUser.save() > > Julian > > >> >> On Wed, Jan 6, 2010 at 11:11 AM, Julian Backes >> <[email protected] <mailto:[email protected]>> wrote: >> >> Does really nobody know something about my problem? Something like >> "this is not possible at the moment" is also ok... :-) >> >> Am 03.01.10 22:46, schrieb Julian Backes: >> >> Hi, >> >> I have the following problem: >> For simplicity, assume I want to store users in the database. >> Before >> storing a user the first time in the database (using >> someNewUser.save), >> I want to create a special unique number for this user (which we >> need in >> our company) and store this number together with the new user. This >> number is based on several values and some of them need to be >> read from >> the database. >> My first idea was to add something to beforeCreate in the meta >> object >> but I'm not sure how to do the computation of the number >> together with >> the save operation in one transaction (which is absolutely >> necessary)? >> And are there better places to do this? >> I read something about putting the whole request in one >> transaction but >> this is not what I want. I'm currently only using the Mapper stuff >> (because I want a pure scala ORM) and not the whole Lift framework. >> >> Thanks in advance, >> Julian >> >> -- >> >> You received this message because you are subscribed to the >> Google Groups "Lift" group. >> To post to this group, send email to [email protected] >> <mailto:[email protected]>. >> >> To unsubscribe from this group, send email to >> >> [email protected]<liftweb%[email protected]> >> >> <mailto:liftweb%[email protected]<liftweb%[email protected]> >> >. >> >> For more options, visit this group at >> http://groups.google.com/group/liftweb?hl=en. >> >> >> >> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Lift" group. >> To post to this group, send email to [email protected] >> <mailto:[email protected]>. >> >> To unsubscribe from this group, send email to >> >> [email protected]<liftweb%[email protected]> >> >> <mailto:liftweb%[email protected]<liftweb%[email protected]> >> >. >> >> For more options, visit this group at >> http://groups.google.com/group/liftweb?hl=en. >> >> >> >> >> >> >> -- >> James A Barrows >> >> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Lift" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<liftweb%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/liftweb?hl=en. >> > > > -- > You received this message because you are subscribed to the Google Groups > "Lift" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<liftweb%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=en. > > > > -- James A Barrows--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
