[odb-users] query::Age --> Incomplete type is not alowed

Tarik BENZ tenchu.tarik at hotmail.fr
Fri Apr 26 03:23:31 EDT 2013


Hi,

I have some troubles to compile my code because I have this error "Incomplete type is not alowed"
My code is :
 #include <string>
#include <memory>   // std::unique_ptr
#include <iostream>
#include <odb/database.hxx>

#include "Database.hxx" // create_database
#include "User.hxx" // create_database
#include <odb/session.hxx>
#include <odb/transaction.hxx>
#include <odb/mssql/database.hxx>

....

        typedef odb::query<User> query;
        typedef odb::result<User> result;

         std::unique_ptr<odb::database> db (create_database ());
        transaction t (db->begin ());
 
        result r (db->query<User> (query::userName == user && query::userPass == password)); // ERROR :  query::userName --> Incomplete type is not alowed
 
        for (result::iterator i (r.begin ()); i != r.end (); ++i)
        {
            cout << "Hello, " << i->first () << endl;
        }
 
        t.commit ();


---------------User Mapping----------
#include <string>
#include <odb/core.hxx>
#include <memory>
#include "Role.hxx"

typedef Role* Role_ptr;

#pragma db object
class User
{
public:
    friend class odb::access;

    User(void);
    User(const int userId, 
        const std::string& userName,
        const std::string& userPass,
        Role_ptr ref_Role)
        : userName_(userName), userId(userId), ref_Role(ref_Role), userPass_(userPass){}
    ~User(void);

    const int getUserId() const
    {
        return this->userId;
    }

    void setUserId(const int Statusode)
    {
        this->userId = userId;
    }

    const std::string getUserName() const
    {
        return this->userName_;
    }

    void setUserName(const std::string& userName)
    {
        this->userName_ = userName;
    }

    const std::shared_ptr<Role> getRefRole() const
    {
        return this->ref_Role;
    }

    void setRefRole(std::shared_ptr<Role> ref_Role)
    {
        this->ref_Role = ref_Role;
    }

    const std::string getUserPass() const
    {
        return this->userPass_;
    }

    void setUserPass(const std::string& userPass)
    {
        this->userPass_ = userPass;
    }

private:
    #pragma db id
    #pragma db get(getUserId) set(setUserId)
    int userId;

    #pragma db get(getUserName) set(setUserName)
    std::string userName_;

    #pragma db get(getUserPass) set(setUserPass)
    std::string userPass_;

    #pragma db get(getRefRole) set(setRefRole)
    std::shared_ptr<Role> ref_Role;
};

-----------------------Can some help me to fix this please? ----------------

 		 	   		  


More information about the odb-users mailing list