hey:
I see Using a natural key (tutorial5.C),I define my XDBUser class,
#ifndef _XDBUSER_H
#define _XDBUSER_H
#include <Wt/Dbo/Dbo>
#include <Wt/Dbo/backend/Postgres>
#include <Wt/Dbo/backend/Sqlite3>
#include <string>
using namespace std;
class XDBUser {
public:
int mUid;
string mNo;
string mName;
string mKey;
template<class Action>
void persist(Action& a)
{
Wt::Dbo:: id(a, mUid, "fuid");
Wt::Dbo::field(a, mNo, "fno");
Wt::Dbo::field(a, mName, "fname");
Wt::Dbo::field(a, mKey, "fkey");
}
};
#endif
but error show in apache error_log file:
[2010-Dec-23 22:24:47.766448] 18171 [/AXXXWWeb.fcgi 62bl7qnCdbHkEphF]
[notice] "Session created (#sessions = 1)"
Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.2.13) Gecko/20101206
Ubuntu/10.04 (lucid) Firefox/3.6.13
[2010-Dec-23 22:24:47.815758] 18171 [/AXXXWWeb.fcgi 62bl7qnCdbHkEphF]
[fatal] "Error: Wt::Dbo::id() called for class C with surrogate key:
Wt::Dbo::dbo_traits<C>::surrogateIdField() != 0"
[2010-Dec-23 22:24:47.816613] 18171 [/AXXXWWeb.fcgi 62bl7qnCdbHkEphF]
[notice] "Session destroyed (#sessions = 0)"
if remove " Wt::Dbo:: id(a, mUid, "fuid");" ,there is no problem.
anthor guestion,how to get id?if no Specifying a natural primary key,it
will auto add id field. when Querying objects,sometimes must get this
id ,how to get joe->id?like here:
(tutorial1.C continued)
dbo::ptr<User> joe = session.find<User>().where("name = ?").bind("Joe");
std::cerr << "Joe has karma: " << joe->karma << std::endl;
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest