[odb-users] Object creator with boost::posix_time::ptime member :
exception from boost
rkadeFR
contact at rkade.fr
Thu Jun 6 10:34:45 EDT 2013
I have an existent database, and try to map the DB with my cpp objects for
some queries.
When I compiled, no errors. But when I run some queries on my objects, I
have
the exception "terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector
<boost::gregorian::bad_day_of_month> >'".
I have some "0000-00-00 00:00:00" datetime in my DB (I can't change that).
This exception is thrown exactly at the moment when I call a function on the
iterator of my result.
ex: iP->GetId()
The documentation says that the object is created at this step of my
program.
(cf http://www.codesynthesis.com/products/odb/doc/manual.xhtml#4.4 )
So i put lots of log, and I can only see the private constructor called,
and then...
nothing except my exception.
Can you explain me the way the iterator works ? And the work around I need
to implement in order to avoid the exception ?
Thank you,
My object is something like :
#include <string>
#include <odb/core.hxx>
#include <boost/date_time.hpp>
#pragma db object table("person")
class Person
{
public:
Person ( const std::string& name, const
boost::posix_time::ptime& dateTime)
: name(name), dateTime(dateTime)
{}
unsigned long GetId() const
{ return this->id; }
const boost::posix_time::ptime GetDateTime() const
{ return this->dateTime; }
const std::string GetName() const
{ return this->name; }
private:
Person() {}
friend class odb::access;
#pragma db column("id") id type("INT(10)") get(GetId)
unsigned long id;
#pragma db column("name") type("VARCHAR(25)") get(GetName)
std::string name;
#pragma db column("dateTime") type("DATETIME") get(GetDateTime)
boost::posix_time::ptime tsAdded;
}
More information about the odb-users
mailing list