AW: [odb-users] Qt BLOB Support

Pascal Stoll past0004 at stud.fh-kl.de
Wed Oct 26 09:41:22 EDT 2011


Sry for the late response, but there where some other stuff to do first.
I made your test. The assert does nothing, but ich checked the size of both values. o1.data.size() was 6 and o2.data.size 0. So same problem. It writes the blob correct into the database, but when i try to read it out, it is always null.
________________________________________
Von: Boris Kolpackov [boris at codesynthesis.com]
Gesendet: Dienstag, 25. Oktober 2011 14:00
Bis: Pascal Stoll
Cc: odb-users at codesynthesis.com
Betreff: Re: [odb-users] Qt BLOB Support

Hi Pascal,

Pascal Stoll <past0004 at stud.fh-kl.de> writes:

> Oh i saw one main difference. Do i have to use all the QSharedPointers/qt
> lazy pointer? I was using the boost ones. Could that be the problem?

No, the kind of pointers you use should be irrelevant. I suggest that
you try this with a very simple, stand-alone test. For example, define
a persistent class like this:

#include <QtCore/QByteArray>

#pragma db object
struct test
{
  #pragma db id
  unsigned long id;

  QByteArray data;
};

And try to store it in the database and then load it back:

test o1;
o1.id = 1;
o1.data = QByteArray ("\0xF1\0x00\0x34\0x45\0x00\0xDE", 6);

{
  transaction t (db->begin ());
  db->persist (o1);
  t.commit ();
}

test o2;
{
  transaction t (db->begin ());
  db->load<test> (1, o2);
  t.commit ();
}

assert (o1.data == o2.data);

If this test works for you, then you need to see what is different
about your code. If the test doesn't work, then I will need more
information about your setup (OS, C++ compiler, database you are
using, ODB version, Qt version) so that I can try and reproduce
this.

Boris



More information about the odb-users mailing list