<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.3.2">
</HEAD>
<BODY>
Dear William,<BR>
    Welcome.<BR>
<BR>
    Are you using 0.5 or the latest version from CVS (which has not quite been formally released yet)?  <BR>
I think this changes slightly based on which version you are using.<BR>
<BR>
    Under the 0.5:<BR>
<BR>
    I think the "Tutorial" on the section Persistent Classes <BR>
<A HREF="http://common-lisp.net/project/elephant/doc/Persistent-Classes.html#Persistent-Classes">http://common-lisp.net/project/elephant/doc/Persistent-Classes.html#Persistent-Classes</A><BR>
shows how to do what you want; I'm pretty sure that it is accurate, but haven't actually done it.<BR>
It shows placing the whole object into the root; I honestly would have to go back to 0.5 to <BR>
say whether this is really necessary or not.  You can try my code snippet below under 0.5 <BR>
and see if it works.  (We have been working on what will be 0.6 for quite a while.)<BR>
<BR>
    Under the most recent CVS version:<BR>
<BR>
    Yes, each time you make-instance a class with a metaclass of :persistent-metaclass, the instance<BR>
is placed in the database with a unique OID.  If you store the OID (for example in the root), you<BR>
can can then close the store-controller, exit lisp, restart LISP, reopen the store-controller, and <BR>
then either do (make-instance  'my-persistent-class :from-oid OID), or, if you have indexed a slot<BR>
of enables class indexing on the class, you could you (get-instance-by-class 'my-persistent-class)<BR>
<BR>
ELE-TESTS> (defclass my-persistent-class ()<BR>
        ((slot1 :accessor slot1)<BR>
         (slot2 :accessor slot2))<BR>
        (:metaclass persistent-metaclass))<BR>
     <BR>
#<PERSISTENT-METACLASS MY-PERSISTENT-CLASS><BR>
ELE-TESTS> (setq x (make-instance 'my-persistent-class))<BR>
; loading system definition from /usr/local/share/lisp/ele-bdb.asd into<BR>
; #<PACKAGE "ASDF1474"><BR>
; registering #<SYSTEM ELE-BDB {AA32BE1}> as ELE-BDB<BR>
STYLE-WARNING: implicitly creating new generic function BUILD-BTREE-INDEX<BR>
#<SLEEPYCAT::BDB-STORE-CONTROLLER {B6C1941}><BR>
ELE-TESTS> (setq x (make-instance 'my-persistent-class))<BR>
#<MY-PERSISTENT-CLASS {B8BA3C1}><BR>
ELE-TESTS> (elephant::oid x)<BR>
14700<BR>
ELE-TESTS> (close-store)<BR>
NIL<BR>
ELE-TESTS> (open-store *default-spec*)<BR>
#<SLEEPYCAT::BDB-STORE-CONTROLLER {A97B6B1}><BR>
ELE-TESTS> (make-instance 'my-persistent-class :from-oid 14700)<BR>
#<MY-PERSISTENT-CLASS {A9FEE69}><BR>
ELE-TESTS> <BR>
<BR>
In the file classindex.lisp, you can find:<BR>
<BR>
(defgeneric get-instances-by-class (persistent-metaclass))<BR>
(defgeneric get-instances-by-value (persistent-metaclass slot-name value))<BR>
(defgeneric get-instances-by-range (persistent-metaclass slot-name start end))<BR>
<BR>
which are very useful for this, and may mean you don't have to store the OID in the root if <BR>
you "enable-class-indexing" on the class.<BR>
<BR>
<BR>
    <BR>
    <BR>
<BR>
On Thu, 2006-03-02 at 17:11 -0500, William Halliburton wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
    <BR>
    <FONT COLOR="#000000">Starting to use elephant with bdb backend. </FONT><BR>
    <BR>
    <FONT COLOR="#000000">Please tell me if the following explanation is correct.</FONT><BR>
    <BR>
    <FONT COLOR="#000000">Each time I make-instance a class with a metaclass of :persistent-metaclass the class is placed into the database with a unique OID. I can retrieve this back with (make-instance 'class :with-oid OID). Now this object in not in the root. Must I place it into the root? How do I remove old objects?</FONT><BR>
    <BR>
    <FONT COLOR="#000000">Thank you,</FONT><BR>
    <FONT COLOR="#000000">William Halliburton</FONT>
<PRE>
<FONT COLOR="#000000">_______________________________________________</FONT>
<FONT COLOR="#000000">elephant-devel site list</FONT>
<FONT COLOR="#000000"><A HREF="mailto:elephant-devel@common-lisp.net">elephant-devel@common-lisp.net</A></FONT>
<FONT COLOR="#000000"><A HREF="http://common-lisp.net/mailman/listinfo/elephant-devel">http://common-lisp.net/mailman/listinfo/elephant-devel</A></FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>