Discussion:
[odb-users] recursive loading
MM
2018-06-15 14:07:54 UTC
Permalink
Hello,
With a raw pointer, when issuing a

auto* ptr = db.load<myclass>(id);

Is it possible to have the pre-load c++ callback of myclass issue
another db.load<myclass>( another_id )

I'm having a core dump in this situation.

myclass member fields refer to other instances of the same type.

Rds,
MM
Boris Kolpackov
2018-06-18 12:37:19 UTC
Permalink
Post by MM
Is it possible to have the pre-load c++ callback of myclass issue
another db.load<myclass>( another_id )
Yes.
Post by MM
I'm having a core dump in this situation.
Must be a bug somewhere.
MM
2018-06-20 12:51:57 UTC
Permalink
Post by Boris Kolpackov
Post by MM
Is it possible to have the pre-load c++ callback of myclass issue
another db.load<myclass>( another_id )
Yes.
Post by MM
I'm having a core dump in this situation.
Must be a bug somewhere.
Sorry, it's not in the pre-load. I have it in the post-load callback.
In fact, I see that in the post-load cb:
db.load<myclass>(another_id)
instantiates a object, but it is empty. It appears it calls in the
generated odb code:

sts.delay_load (id, obj, ig.position ());

Apparently, the auto_lock is not locked.

Does any of this make sense?
Boris Kolpackov
2018-06-23 16:00:26 UTC
Permalink
Post by MM
Does any of this make sense?
Perhaps you are loading the same object recursively. Try to create a
session before the transaction.

MM
2018-06-22 13:38:52 UTC
Permalink
Post by MM
Post by Boris Kolpackov
Post by MM
Is it possible to have the pre-load c++ callback of myclass issue
another db.load<myclass>( another_id )
Yes.
Post by MM
I'm having a core dump in this situation.
Must be a bug somewhere.
Sorry, it's not in the pre-load. I have it in the post-load callback.
db.load<myclass>(another_id)
instantiates a object, but it is empty. It appears it calls in the
sts.delay_load (id, obj, ig.position ());
Apparently, the auto_lock is not locked.
Does any of this make sense?
An update here.
In the post-load callback, I've replaced the call to
db.load<myclass>(another_id)
//// returns an object but it remains empty
//// tracer shows that a SELECT query is issued indeed

with
auto res = db.query<myclass>( query::id == another_id);
for (auto& obj: res)
//// obj is correctly populated here

It seems db.load() inside of post-load callback of the 1st db.load()
doesn't work. But db.query does.

MM
Loading...