[elephant-devel] Inherited slots don't get persisted

Ian Eslick eslick at media.mit.edu
Wed Dec 24 22:28:23 UTC 2008


Yes, the standard object slots are 'transient' by default.  Any  
subclass which is persistent inherits the transient semantics so what  
you are seeing is the right default behavior.  The only way to make  
them persistent is to shadow the old definition with a new persistent  
definition in the subclass, so I'm not inclined to change the default  
behavior.

You could look at adding an :persistent-inherit as a class option to  
do this.  But I think that it is a bit dirty since now you can have  
one subclass with different slot behavior than another.

You could also write a method which overrides one of the  
initialization phases for the new subclass specifically which upgrades  
the effective slot definitions so they are now persistent slot  
metaobjects.

Ian


On Dec 24, 2008, at 3:15 PM, Yarek Kowalik wrote:

> I have two classes, one an "ephemeral" and one persistent.  The  
> persistent class inherits from the ephemeral class.   When I copy  
> slot values from an ephemeral instance to persistent instance, only  
> the slots that are redefined in the persistent class get persisted  
> properly, the other inherited slots are not, as if they were marked  
> transient by default.  Is this the correct behaviour?   Is there a  
> way to make all inherited slots persistent?
>
> In the example below only slots 'last-name' and 'username' get  
> persisted when copying from 'site-user-ephemeral instance to 'site- 
> user instance.
>
> Yarek
>
> (defclass site-user-ephemeral ()
>   ((first-name
>      :accessor    site-user-first-name
>      :initarg    :first-name
>      :type    string)
>    (last-name
>      :accessor    site-user-last-name
>      :initarg    :last-name
>      :type    string)
>    (username
>      :accessor    site-user-username
>      :initarg    :username
>      :type    string)
>    (email
>      :accessor    site-user-email
>      :initarg    :email
>      :type    string)
>    (password
>      :accessor    site-user-password
>      :initarg    :password
>      :type    string))
>   (:documentation "object for storing user data"))
>
> (defpclass site-user (site-user-ephemeral)
>   ((last-name)
>    (username
>      :index    t))
>   (:index t)
>   (:documentation "persistent object for storing user data"))
> _______________________________________________
> elephant-devel site list
> elephant-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/elephant-devel





More information about the elephant-devel mailing list