Hi!
During our work with the new associations in elephant-unstable I've run
into the issue that return associations in the 1 to N case are not made
persistent in the store and are lost as soon as the store is closed and
then re-opened.
Datastore: BDB 4.5
Lisp: sbcl 1.0.17
OS: Mac OS X.4
The attached sample program illustrates the problem.
Thanks in advance for any assistance!
Best regards,
Marc
(elephant:open-store '(:BDB "/tmp/db"))
(elephant:defpclass A ()
((ic :accessor ic
:initarg :ic
:associate B)
(id :accessor id
:initarg :id
:type string
:index t)))
(elephant:defpclass B ()
((ii :accessor ii
:associate (A ic)
:documentation "Intended as 1 to N relation: B can point to many
As, but each A must point to exactly one B")
(id :accessor id
:initarg :id
:type string
:index t)))
(defun make-A (id)
(make-instance 'A :id id))
(defun make-B (id)
(let
((b (make-instance 'B :id id))
(alist (map 'list #'make-A '("a1" "a2" "a3"))))
(dolist (a alist)
(setf (ic a) b))))
(dolist (b-id '("b1" "b2" "b3"))
(make-B b-id))
(defvar as (elephant:get-instances-by-class 'A))
(defvar bs (elephant:get-instances-by-class 'B))
(format t "With open store: first a has id ~a and ic ~a~&" (id (first as)) (ic
(first as)))
;;Prints: With open store: first a has id a1 and ic #<B oid:2>
(format t "With open store: first b has id ~a and ii ~a~&" (id (first bs)) (ii
(first bs)))
;;Prints: #<B oid:2>With open store: first b has id b1 and ii (#<A oid:4>
;; #<A oid:6>
;; #<A oid:7>)
(elephant:close-store)
(elephant:open-store '(:BDB "/tmp/db"))
(setf as (elephant:get-instances-by-class 'A))
(setf bs (elephant:get-instances-by-class 'B))
(format t "With reopened store: first a has id ~a and ic ~a" (id (first as))
(ic (first as)))
;;Prints: With reopened store: first a has id a1 and ic #<B oid:2>
(format t "With reopened store: first b has id ~a and ii ~a" (id (first bs))
(ii (first bs)))
;;Prints: With reopened store: first b has id b1 and ii NIL_______________________________________________
elephant-devel site list
[email protected]
http://common-lisp.net/mailman/listinfo/elephant-devel