Hey, 2010/7/28 changwon lee <[email protected]>: > after creating one user and add child post and flushing session, > > User *user2 = new User(); > user2->name = "Daisy"; > user2->password = "Secret2"; > user2->role = User::Visitor; > user2->karma = 12; > > dbo::ptr<User> user2Ptr = session.add(user2); > dbo::ptr<Post> postPtr = session.add(new Post()); > postPtr.modify()->user = user2Ptr; > > session.flush(); > user2Ptr.remove(); > transaction.commit(); > > I am currently implementing new SqlConnection based on Qt Sql ODBC > driver. (to access mdb)
That's nice! Are you planning on making it available ? Although the interface for SqlConnection has not changed, the latest git version of Wt contains a quasi-rewrite of large parts of Wt::Dbo and thus you may to test your connection against the latest git version ? > when I execute above example in sqlite, it seems that post is deleted > not automatically. Indeed, Wt::Dbo will not 'cascade' deletes for you. > and it is strange that foreign key of post holds deleted user id. > is this correct result? I don't know sqlite well. doesn't references > keyword check referential integrity? Only very recent versions of Sqlite3 (since 3.6.19) will actually check and enforce referential integrity (see also: http://www.sqlite.org/foreignkeys.html). > and I want to know which one is desirable operation when I delete user > by user.remove(). > > 1. child post have to be removed automatically too > 2. or do I have to remove post before user? IMO, Wt::Dbo should not automatically delete the dependent objects. If somebody wants that behaviour, then he should let the database do this 'on delete cascade'. Eventually, we will need to foresee a syntax option which can be passed to the dbo::hasMany() function which sets this constraint when doing createSchema(). Regards, koen ------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://ad.doubleclick.net/clk;226879339;13503038;l? http://clk.atdmt.com/CRS/go/247765532/direct/01/ _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
