Giter Club home page Giter Club logo

Comments (8)

andyjefferson avatar andyjefferson commented on July 20, 2024

In which case you look at classes org.datanucleus.store.query.Query and/or org.datanucleus.ExecutionContextImpl#getObjectFromLevel2Cache and look at one of those classes making sure that the "Class" is initialised, USING THE ClassLoaderResolver (part of the ExecutionContext).

The only other thing to note from the second stack trace is that when performing a query, depending on the query executed I would expect the candidate class of the query to be "initialised" at that point, in which case the class will be registered with the EnhancementHelper. You provide no definition of the query or class so no comment possible on that situation.

Also note that current codebase (master) is where any proposed changes need to be, since that is what is developed.

from datanucleus-cache.

awarrior avatar awarrior commented on July 20, 2024

I think the reason is that it only uses objectid to get l2cache and do not check whether this 'class' has been registered or not. Here is what I found in the source:

// ExecutionContextImpl.java

Level2Cache l2Cache = nucCtx.getLevel2Cache();
CachedPC cachedPC = l2Cache.get(id);
if (cachedPC != null)
{
// Create active version of cached object with ObjectProvider connected and same id
ObjectProvider op = nucCtx.getObjectProviderFactory().newForCachedPC(this, id, cachedPC);

// ObjectProviderFactoryImpl.java

public ObjectProvider newForCachedPC(ExecutionContext ec, Object id, CachedPC cachedPC)
{
AbstractClassMetaData cmd = ec.getMetaDataManager().getMetaDataForClass(cachedPC.getObjectClass(), ec.getClassLoaderResolver());
ObjectProvider op = getObjectProvider(ec, cmd);
op.initialiseForCachedPC(cachedPC, id);
return op;
}

// StateManagerImpl.java

public void initialiseForCachedPC(CachedPC cachedPC, Object id)
{
// Create a new copy of the input object type, performing the majority of the initialisation
initialiseForHollow(id, null, cachedPC.getObjectClass());

from datanucleus-cache.

andyjefferson avatar andyjefferson commented on July 20, 2024

which doesnt explain what the query is being invoked, and why the candidate class is not "initialised"

from datanucleus-cache.

awarrior avatar awarrior commented on July 20, 2024

Here is the definition of the query from client. Any help to judge this question?

query = pm.newQuery(MRoleMap.class, "principalName == t1 && principalType == t2 && role.roleName == t3");
query.declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3");
query.setUnique(true);
mRoleMember = (MRoleMap) query.executeWithArray(userName, principalType.toString(), roleName);

from datanucleus-cache.

andyjefferson avatar andyjefferson commented on July 20, 2024

So why isn't the MRoleMap class initialised when it goes through the query compilation etc and before it gets to processing the query result?

from datanucleus-cache.

awarrior avatar awarrior commented on July 20, 2024

Do you mean the candidateClass in org.datanucleus.store.query.Query should be initialized after pm.newQuery? Maybe more traces have to be printed in setCandidateClass or around compilation.getCandidateClass()

from datanucleus-cache.

andyjefferson avatar andyjefferson commented on July 20, 2024

I would expect the (Class)MetaData (annotations, XML) for the candidate class to be loaded, populated and initialised. The call to populate of the MetaData should call initialize on the class object, which should "register" it. You will see usage of "cmd" in the query objects, that is the MetaData for the candidate class. The log also tells you when metadata is loaded.

from datanucleus-cache.

andyjefferson avatar andyjefferson commented on July 20, 2024

Closing since no testcase provided, and no apparent willingness to develop a fix for whatever is being seen. Post back here with testcase and/or pull request as required and this can be reopened

from datanucleus-cache.

Related Issues (7)

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.