Giter Club home page Giter Club logo

Comments (5)

josecaster avatar josecaster commented on June 15, 2024

Changed a few things in Root

...
@Table(Store.class)
    private final Lazy<List<Store>> stores = Lazy.Reference(new ArrayList<>(32));
...
/**
     * This gets the lazy field by the provided class
     * @param c
     * @return
     * @param <T>
     */
    public <T extends SuperDao> Lazy<List<T>> getLazyByClass(Class<? extends SuperDao> c) {
        if (c != null) {
            for (Field field : Root.class.getDeclaredFields()) {
                if (field.isAnnotationPresent(Table.class)) {
                    Table annotation = field.getAnnotation(Table.class);
                    if(annotation.value().equals(c)) {
                        try {
                            return (Lazy<List<T>>) field.get(this);
                        } catch (IllegalAccessException e) {
                            throw new RuntimeException(e);
                        }
                    }
                }
            }
        }
        return null;
    }

However I notice 3 things. The load method is never called because the Object ID is 0 each time.

Screenshot 2024-03-02 135615
Screenshot 2024-03-02 141426
Screenshot 2024-03-02 141445

from store.

hg-ms avatar hg-ms commented on June 15, 2024

Hello,
As I can’t run your code, I can give you some hints only.

  1. By default, we use a lazy storing strategy, this means that a store will stop traversing references as soon as an already stored object reference is encountered. Please see https://docs.eclipsestore.io/manual/storage/storing-data/lazy-eager-full.html.
  2. Always call the store on the modified objects.
  3. During development It may be easier to delete the storage files to enforce creating a new storage then updating and storing all modified objects.

Regarding the empty Lazy-Reference I guess that you stored a version that has a null reference instead of an initialized List. To solve that you need to replace the existing Lazy-Reference with new one referencing an initialized List and then store the Root object. (or simply delete the storage)

Another potential problem I saw is the store in the ‘update’ method. This store stores the Lazy-Reference but will not update the referenced list due to the lazy storing strategy. This will cause new objects added to the list not to be stored. When adding new items to the list you need to store the list and not the Lazy.

from store.

josecaster avatar josecaster commented on June 15, 2024

WORKED!

Updated the update method :

public T update(T dao, InterExecutable<T, T> update) {
        Root root = (Root) storageManager.root();
        List<T> list = root.getListByClass(typeParameterClass);

        if (StringUtils.isNotBlank(dao.getUuId())) {
            T daoExist = get(dao.getUuId());
            if (update != null && daoExist != null) {
                update.build(daoExist);// this method is provided to update the existed instance
                daoExist.setUuId(dao.getUuId());// to prevent people from overriding the UUID
            } else {
                return null;
            }
        } else {
            dao.setUuId(UUID.randomUUID().toString());// if new we will add to the list
            list.add(dao);
        }
        List listByClass = root.getListByClass(typeParameterClass);
        storageManager.store(listByClass);

        return get(dao.getUuId());
    }

and created a new storage path.

  • No Storing Lazy Object only store the Lazy parameters
  • I think the main take away from this is to call the storeRoot() method if you make changes to the root object.

from store.

zdenek-jonas avatar zdenek-jonas commented on June 15, 2024

Can be this Issue closed?

from store.

josecaster avatar josecaster commented on June 15, 2024

Yes thank you

from store.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.