dao::fetch_by_query() issue

Forum for posting problems using QxOrm library

dao::fetch_by_query() issue

Postby marat » Mon Aug 20, 2012 8:36 pm

I'm having an issue, where I try to retrieve objects from a DB table for one particular object.

Code: Select all
QList<boost::shared_ptr<OBJ> > rowsList;
qx::QxSqlQuery query;
qx::dao::fetch_by_query(query, rowsList);  // <--- see below


An assertion is raised from QxDao.h insertNewItem(T&t, qx::dao::details::QxDao_Helper_Container<T>& dao) in the line
Code: Select all
 qx::IxDataMember * pId = dao.getDataId(); qAssert(pId);  // line # 86


It looks like dao.getDataId() returns NULL. Do you know why this may be ?


(gdb) where
#0 0x0000003096c329a5 in raise () from /lib64/libc.so.6
#1 0x0000003096c34185 in abort () from /lib64/libc.so.6
#2 0x000000366f869a74 in qt_message_output(QtMsgType, char const*) () from /usr/lib64/libQtCore.so.4
#3 0x000000366f869c52 in ?? () from /usr/lib64/libQtCore.so.4
#4 0x000000366f869e05 in qFatal(char const*, ...) () from /usr/lib64/libQtCore.so.4
#5 0x00000000004375a8 in qx::dao::detail::QxDao_FetchAll_Container<QList<boost::shared_ptr<OBJ> > >::insertNewItem (t=..., dao=...)
at /.../qxorm/1.2.4/include/QxDao/../../inl/QxDao/QxDao_FetchAll.inl:88
#6 0x0000000000436334 in qx::dao::detail::QxDao_FetchAll_Container<QList<boost::shared_ptr<OBJ> > >::fetchAll
(query=..., t=..., pDatabase=0x0, columns=...)
at /.../common/qxorm/1.2.4/include/QxDao/../../inl/QxDao/QxDao_FetchAll.inl:74
#7 0x00000000004351ba in qx::dao::detail::QxDao_FetchAll<QList<boost::shared_ptr<OBJ> > >::fetchAll (query=
..., t=..., pDatabase=0x0, columns=...)
at /.../qxorm/1.2.4/include/QxDao/../../inl/QxDao/QxDao_FetchAll.inl:119
#8 0x000000000043438a in qx::dao::fetch_by_query<QList<boost::shared_ptr<OBJ> > > (query=..., t=...,
marat
 
Posts: 15
Joined: Tue Jul 17, 2012 8:23 pm

Re: dao::fetch_by_query() issue

Postby qxorm » Thu Aug 23, 2012 6:31 am

Hi,

It looks like dao.getDataId() returns NULL. Do you know why this may be ?

You don't have any ID registered for your class OBJ.
In your qx::register_class<OBJ> function, I think you have only t.data(...) calls, and not a t.id(...) call.
For example, in qxBlog tutorial :
Code: Select all
namespace qx {
template <> void register_class(QxClass<author> & t)
{
   t.id(& author::m_id, "author_id");

   t.data(& author::m_name, "name");
   t.data(& author::m_birthdate, "birthdate");
   t.data(& author::m_sex, "sex");
   // etc...
}}
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 3 guests