AW: [odb-users] One-to-many bidirectional relationship without
intermediary table
Mocnik Marko
marko.mocnik at lisec.com
Tue Oct 15 12:15:10 EDT 2019
What am I doing wrong?
I can't get the generated code to compile (sorry about the german compiler messages but I guess the meaning is clear?):
TestiAll-odb-pgsql.h(151): error C2027: Verwendung des undefinierten Typs "odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>"
TestiAll-odb-pgsql.h(151): note: Siehe Deklaration von "odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>"
TestiAll-odb-pgsql.cpp(150): error C2664: "void odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::bind(odb::pgsql::bind *,odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::image_type &,odb::pgsql::statement_kind)" : Konvertierung von Argument 2 von "odb::access::object_traits_impl<testi,odb::id_pgsql>::image_type" in "odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::image_type &" nicht m"glich
TestiAll-odb-pgsql.cpp(162): error C2664: "bool odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::grow(odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::image_type &,bool *)" : Konvertierung von Argument 1 von "odb::access::object_traits_impl<testi,odb::id_pgsql>::image_type" in "odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::image_type &" nicht m"glich
TestiAll-odb-pgsql.cpp(183): error C2664: "bool odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::get_null(const odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::image_type &)" : Konvertierung von Argument 1 von "const odb::access::object_traits_impl<testi,odb::id_pgsql>::image_type" in "const odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::image_type &" nicht m"glich
TestiAll-odb-pgsql.cpp(183): note: Ursache: Konvertierung von "const odb::access::object_traits_impl<testi,odb::id_pgsql>::image_type" in "const odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::image_type" nicht m"glich
TestiAll-odb-pgsql.cpp(183): note: Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden
TestiAll-odb-pgsql.cpp(191): error C2665: "odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::init": Durch keine der 2 Überladungen konnten alle Argumenttypen konvertiert werden.
TestiAll-odb-pgsql.h(330): note: kann "void odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::init(odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::value_type &,const odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::image_type &,odb::database *)" sein
TestiAll-odb-pgsql.h(325): note: oder "bool odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::init(odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::image_type &,const odb::access::composite_value_traits<testi2::id_type,odb::id_pgsql>::value_type &,odb::pgsql::statement_kind)"
TestiAll-odb-pgsql.cpp(191): note: bei Anpassung der Argumentliste "(odb::access::object_traits<testi2>::id_type, const odb::access::object_traits_impl<testi,odb::id_pgsql>::image_type, odb::database *)"
// ----------- TestiAll.h ----------------
struct testi2;
#pragma db object
struct testi
{
testi () {}
testi (int asdf, const std::string& desc) : asdf(asdf), description(desc) {}
#pragma db inverse(id.asdf)
std::vector<std::shared_ptr<::testi2> > children;
#pragma db id
int asdf;
std::string description;
};
#pragma db object
struct testi2
{
testi2() : parent(new testi()) {}
testi2(int asdf, int qwer, const std::string &m) : parent(new testi(asdf, "")), qwer(qwer), moredata(m) {}
#pragma db transient
std::shared_ptr<testi> parent;
#pragma db transient
int qwer;
#pragma db value
struct id_type
{
id_type() {}
id_type(int asdf_, int qwer_) : asdf(asdf_), qwer(qwer_) {}
#pragma db points_to(testi)
int asdf;
int qwer;
};
std::string moredata;
#pragma db member(id) virtual(id_type) id column("") \
get (id_type(this.parent->asdf, this.qwer)) \
set (this.parent = std::shared_ptr<::testi>(new ::testi((?).asdf, "")); this.qwer = (?).qwer)
};
inline bool operator < (const testi2::id_type &l, const testi2::id_type &r)
{
if (l.asdf != r.asdf)
return l.asdf < r.asdf;
return l.qwer < r.qwer;
}
More information about the odb-users
mailing list