[odb-users] Unable to Find Suitable Accessor Function Error
Greg McKeever
organgtool at gmail.com
Wed Apr 22 22:38:56 EDT 2015
I am trying to compile a simple class using ODB 2.4.0 on an Ubuntu Linux
machine and I keep getting the following error:
BaseTransferObject.h:24:34: error: unable to find suitable accessor
function 'getPrimaryKey'
The command I am using to compile the class is:
/usr/local/bin/odb -d sqlite BaseTransferObject.h
The source of the file is:
/*
* BaseTransferObject.h
*
* Created on: Jul 29, 2013
* Author: Greg McKeever
*/
#ifndef BASETRANSFEROBJECT_H_
#define BASETRANSFEROBJECT_H_
#pragma db object
class BaseTransferObject
{
public:
BaseTransferObject();
virtual ~BaseTransferObject();
void setPrimaryKey( long thePrimaryKey );
long getPrimaryKey();
private:
#pragma db id column("idfr") get(getPrimaryKey) set(setPrimaryKey)
long primaryKey;
};
#endif /* BASETRANSFEROBJECT_H_ */
I am specifying the getter and setter in the pragma since I get the
following error if I do not explicitly set them:
BaseTransferObject.h:23:10: error: data member 'primaryKey' is private and
no suitable accessor function could be automatically found
BaseTransferObject.h:23:10: info: consider making class 'odb::access' a
friend of class 'BaseTransferObject'
BaseTransferObject.h:23:10: info: or use '#pragma db get' to explicitly
specify the accessor function or expression
I tried adding odb::access as a friend class and that fixed this problem,
although I think it created other problems. Could you please help me as I
can not find anything in the ODB manual about what I am doing wrong?
Thanks,
Greg
More information about the odb-users
mailing list