[odb-users] [Question] persist a custom object class

Myoungkyu Song mksong at vt.edu
Fri Dec 17 00:26:42 EST 2010


# ODB version: 1.0.0
# OS: Linux 2.6.32-26-generic-Ubuntu
# Compiler: g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3

Hi,

I would like to ask about persisting the custom class object. For
example, consider the followings;
============================================================
class SequenceModel : public x10::lang::Object   {
    public:
    RTT_H_DECLS_CLASS

    void _instance_init();

    x10aux::ref<x10::lang::String> FMGL(name);
    x10aux::ref<x10::lang::String> FMGL(sequence);
 ...
}
============================================================

Then, in order to pass to the ODB-DB-API generator, I put the
“#pragma” like this;
============================================================
#include <odb/core.hxx>	// (1) ODB

typedef x10aux::ref<x10::lang::String> StringRef;	// (2) ODB
#pragma db value(StringRef) type("TEXT NOT NULL") // (2) ODB

#pragma db object	// (3) ODB
class SequenceModel : public x10::lang::Object   {
public:
    RTT_H_DECLS_CLASS

    void _instance_init();

    StringRef FMGL(name);		// (4) ODB
    StringRef FMGL(sequence);	// (4) ODB
 ...
private:
    SequenceModel() {} 	// (5) ODB

    friend class odb::access; 	// (6) ODB

    #pragma db id auto        	// (7) ODB
    unsigned long id_; 		// (7) ODB
};
============================================================

And then, I was wondering whether I need to modify “
/usr/local/include/odb/mysql/traits.hxx” for the specialization of the
custom object class, “StringRef”?

Best regards,
Myoungkyu Song



More information about the odb-users mailing list