Interface ObjectClass

    • Method Detail

      • callConstructor

        void callConstructor​(boolean flag)
        advises db4o to try instantiating objects of this class with/without calling constructors.

        Not all JDKs / .NET-environments support this feature. db4o will attempt, to follow the setting as good as the environment supports. In doing so, it may call implementation-specific features like sun.reflect.ReflectionFactory#newConstructorForSerialization on the Oracle JVM (not available on other VMs) and FormatterServices.GetUninitializedObject() on the .NET framework (not available on CompactFramework).

        This setting may also be set globally for all classes in CommonConfiguration.callConstructors(boolean).

        In client-server environment this setting should be used on both client and server.

        Parameters:
        flag - - specify true, to request calling constructors, specify false to request not calling constructors.
        See Also:
        Configuration.callConstructors(boolean)
      • cascadeOnActivate

        void cascadeOnActivate​(boolean flag)
        sets cascaded activation behaviour.

        Setting cascadeOnActivate to true will result in the activation of all member objects if an instance of this class is activated.

        The default setting is false.

        In client-server environment this setting should be used on both client and server.

        Can be applied to an open ObjectContainer.

        Parameters:
        flag - whether activation is to be cascaded to member objects.
        See Also:
        ObjectField.cascadeOnActivate(boolean), ObjectContainer.activate(java.lang.Object, int), Using callbacks, Why activation?
      • cascadeOnDelete

        void cascadeOnDelete​(boolean flag)
        sets cascaded delete behaviour.

        Setting cascadeOnDelete to true will result in the deletion of all member objects of instances of this class, if they are passed to ObjectContainer.delete(Object).

        Caution !
        This setting will also trigger deletion of old member objects, on calls to ObjectContainer.store(Object).

        An example of the behaviour:
        ObjectContainer con;
        Bar bar1 = new Bar();
        Bar bar2 = new Bar();
        foo.bar = bar1;
        con.store(foo); // bar1 is stored as a member of foo
        foo.bar = bar2;
        con.store(foo); // bar2 is stored as a member of foo

        The last statement will also delete bar1 from the ObjectContainer, no matter how many other stored objects hold references to bar1.

        The default setting is false.

        In client-server environment this setting should be used on both client and server.

        This setting can be applied to an open object container.

        Parameters:
        flag - whether deletes are to be cascaded to member objects.
        See Also:
        ObjectField.cascadeOnDelete(boolean), ObjectContainer.delete(Object), Using callbacks
      • cascadeOnUpdate

        void cascadeOnUpdate​(boolean flag)
        sets cascaded update behaviour.

        Setting cascadeOnUpdate to true will result in the update of all member objects if a stored instance of this class is passed to ObjectContainer.store(Object).

        The default setting is false. Setting it to true may result in serious performance degradation.

        In client-server environment this setting should be used on both client and server.

        This setting can be applied to an open object container.

        Parameters:
        flag - whether updates are to be cascaded to member objects.
        See Also:
        ObjectField.cascadeOnUpdate(boolean), com.db4o.ObjectContainer#set, Using callbacks
      • compare

        void compare​(ObjectAttribute attributeProvider)
        Deprecated.
        since version 7.0
        registers an attribute provider for special query behavior.

        The query processor will compare the object returned by the attribute provider instead of the actual object, both for the constraint and the candidate persistent object.

        In client-server environment this setting should be used on both client and server.

        Parameters:
        attributeProvider - the attribute provider to be used
      • enableReplication

        void enableReplication​(boolean setting)
        Deprecated.
        Must be called before databases are created or opened so that db4o will control versions and generate UUIDs for objects of this class, which is required for using replication.
        Parameters:
        setting -
      • generateUUIDs

        void generateUUIDs​(boolean setting)
        generate UUIDs for stored objects of this class. This setting should be used before the database is first created.

        Parameters:
        setting -
      • generateVersionNumbers

        void generateVersionNumbers​(boolean setting)
        Deprecated.
        As of version 8.0 please use FileConfiguration.generateCommitTimestamps(boolean) instead
        generate version numbers for stored objects of this class. This setting should be used before the database is first created.

        Parameters:
        setting -
      • indexed

        void indexed​(boolean flag)
        turns the class index on or off.

        db4o maintains an index for each class to be able to deliver all instances of a class in a query. If the class index is never needed, it can be turned off with this method to improve the performance to create and delete objects of a class.

        Common cases where a class index is not needed:
        - The application always works with sub classes or super classes.
        - There are convenient field indexes that will always find instances of a class.
        - The application always works with IDs.

        In client-server environment this setting should be used on both client and server.

        This setting can be applied to an open object container.

      • maximumActivationDepth

        void maximumActivationDepth​(int depth)
        sets the maximum activation depth to the desired value.

        A class specific setting overrides the global setting

        In client-server environment this setting should be used on both client and server.

        This setting can be applied to an open object container.

        Parameters:
        depth - the desired maximum activation depth
        See Also:
        Why activation?, cascadeOnActivate(boolean)
      • minimumActivationDepth

        void minimumActivationDepth​(int depth)
        sets the minimum activation depth to the desired value.

        A class specific setting overrides the global setting

        In client-server environment this setting should be used on both client and server.

        This setting can be applied to an open object container.

        Parameters:
        depth - the desired minimum activation depth
        See Also:
        Why activation?, cascadeOnActivate(boolean)
      • minimumActivationDepth

        int minimumActivationDepth()
        gets the configured minimum activation depth. In client-server environment this setting should be used on both client and server.

        Returns:
        the configured minimum activation depth.
      • objectField

        ObjectField objectField​(java.lang.String fieldName)
        returns an ObjectField object to configure the specified field.

        Parameters:
        fieldName - the name of the field to be configured.

        Returns:
        an instance of an ObjectField object for configuration.
      • persistStaticFieldValues

        void persistStaticFieldValues()
        turns on storing static field values for this class.

        By default, static field values of classes are not stored to the database file. By turning the setting on for a specific class with this switch, all non-simple-typed static field values of this class are stored the first time an object of the class is stored, and restored, every time a database file is opened afterwards, after class meta information is loaded for this class (which can happen by querying for a class or by loading an instance of a class).

        To update a static field value, once it is stored, you have to the following in this order:
        (1) open the database file you are working against
        (2) make sure the class metadata is loaded
        objectContainer.query().constrain(Foo.class); // Java
        objectContainer.Query().Constrain(typeof(Foo)); // C#
        (3) change the static member
        (4) store the static member explicitly
        objectContainer.store(Foo.staticMember); // Java

        The setting will be ignored for simple types.

        Use this setting for constant static object members.

        This option will slow down the process of opening database files and the stored objects will occupy space in the database file.

        In client-server environment this setting should be used on both client and server.

        This setting can NOT be applied to an open object container.

      • rename

        void rename​(java.lang.String newName)
        renames a stored class.

        Use this method to refactor classes.

        In client-server environment this setting should be used on both client and server.

        This setting can NOT be applied to an open object container.

        Parameters:
        newName - the new fully qualified class name.
      • storeTransientFields

        void storeTransientFields​(boolean flag)
        allows to specify if transient fields are to be stored.
        The default for every class is false.

        In client-server environment this setting should be used on both client and server.

        This setting can be applied to an open object container.

        Parameters:
        flag - whether or not transient fields are to be stored.