Shirish Ranjit
shirishranjit.com-
iPhone Managed Objects – Can’t find model for source store
Posted on January 4th, 2010 No commentsIf you get an error reason in manage objects as follows:
” Can’t find model for source store “
this means that either your object model and generated/coded model codes are out of sync or your db is not migrated/upgraded correctly to the new version. When you have many models with many relationships, it may be difficult to spot the issue. The easy way resolve this issue is to regenerate all the code.
Following is the code to create options on the store context to migrate automatically to new version of db.
NSDictionary *optionsForSTore = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];You can delete the whole db so that you do not have this issue. However, you will loose all the data.
I have spent many hours to find easier way to trace this issue. As the compiler does not catch the mis-match in the model-code and there is not much feedback on error on the managed objects, this becomes a mysterious issue.
The easiest way to avoid this issue is always regenerate the entity that you are modifying and have the options set in the managed context.
-
iPhone Compile Error accessing unknown component of a property
Posted on December 18th, 2009 No commentsWhen you get a compile error as follows:
" error accessing unknown ??? component of a property "This means that you are missing an import statment. The missing import is the one that you have the error. Once you add the missing import, the program shall compile correctly.
-
Google App Engine Datanucleus Enhancer – Nullpointer
Posted on November 20th, 2009 No commentsIn some cases, when Datanucleus Enhancer throws exception as follows:
An internal error occurred during: “DataNucleus Enhancer”. java.lang.NullPointerException
If you see such error that means that the Enhancer cannot traverse through the source tree to find the classes because the tree was too large. In such case, you can add the path to the data classes in the Google App Engine configuration window as follows:
1)Bring up your Google App Engine setting window
2)click on “ORM” choice: – click on the src and edit the path to the data classes package.
3) Save it and do your Datanucleus Enhancer.
Here is the URL for bug report http://code.google.com/p/googleappengine/issues/detail?id=1862
-
Google App Engine 1.2.6 Error Running in Eclipse with Older version Projects
Posted on October 30th, 2009 No commentsThe new App Engine release causes older projects in Eclipse to crash. The new SDK release require a VM parameter in the run command for eclipse to run correctly.
The new project automatically adds the parameter in run configuration. Following is the vm parameter that you need to add if you are using the older projects in the Eclipse.
-javaagent:/Library/Genuitec/Common/plugins/
com.google.appengine.eclipse.sdkbundle_1.2.6.v200910130758/
appengine-java-sdk-1.2.6/lib/agent/appengine-agent.jar
-
Pearls of Objective-c NSMutableDictionary (iPhone Development):
Posted on October 20th, 2009 No comments
NSMutableDictionary does not seem to store my data but I do not get any error when setting or getting the data, what is the issue?
In almost all cases, in objective-c, all the variables need to be initialized before using them. The iphone program crashes horribly when the program come across un-initialized variables. However, there are exception to this rule. One such case is NSMutableDictionary typed object.
An un-initialized NSMutableDictionary does not crash the application or throw any type of exception when doing operation on the variable. You will be able to set and get objects without any issue. The only program is that nothing happens.
You think that you put something in the Dictionary but nothing gets stored on it. So, you wonder if there are issue with retain which takes you down different pathway on debugging the issue.
The issue here is that NSMutableDictionary is not initialized yet. So, the operation that you did is on a “nil” object. However, the application does not throw any exception.
Thus, if you come across this case, make sure you check if you have done the initialization on the NSMutableDictionary variable.
-
Google App Engine: Memcache – How can you create a multiple Memcache?
Posted on October 14th, 2009 No comments(http://code.google.com/appengine/docs/java/memcache/overview.html)
Google App Engine provides Memcache as a part of App Engine. Memcache implements the JCache interface (javax.cache).
The App Engine provides MemcacheService and implementation of jCache API. There are a lot of useful features that the jCache does not provide.
Here is how one can create a multiple Memcache in App Engine.
MemcacheService cacheA = MemcacheServiceFactory.getMemcacheService();
cacheLock.setNamespace( “A” );
MemcacheService cacheB = MemcacheServiceFactory.getMemcacheService();
cacheTxnLocked.setNamespace( “B” );
MemcacheService cacheC = MemcacheServiceFactory.getMemcacheService();
cacheAllTxns.setNamespace( “C” );
Once you create the Memcache using the MemcacheServiceFactory, you need to set the Namespace. The “Namespace” causes the cache to be different.
So, if you do not set the “Namespace” on the cache, then all the cache that you get from the MemcacheService will be the same.
A pattern to use Memcache in the App Engine (or in any application server) is to use a Singleton to hold the cache. Singleton allows to initialize the different caches and works as a Facade to the Memcache.
This design has many useful features. Few of those are:
- hides the actual implementation of Memcache which allows to change cache without impacting the user of the cache.
- allows data access objects to be cached such that the cached persistence objects are managed by same persistence context.
-
Kathmandu Metro
Posted on November 4th, 2008 No commentsThe online news and news analysis site www.kathmandumetro.com and www.kantipuronline.com.
Uncategorized -
Financial Crisis of 2008
Posted on October 20th, 2008 No commentsIs financial crisis over? What is the implication of this crisis? Are we in creative distruction of the industry? If so what is the creation as we know what is distroyed? Is the crisis strengthening the gobal financial ties? How does the financial map change?
Uncategorized -
Hibernate Technology
Posted on August 13th, 2008 No commentsAbout hibernate technology
Uncategorized -
org.hibernate. QueryParameterException: could not locate named parameter
Posted on August 13th, 2008 No commentsWhen you query the database in Hibernate using NamedQuery you may run into this errororg.hibernate.QueryParameterException: could not locate named parameter [parm1]Chances are that you are either trying to set a parmeter to the query which infact doesnt exist in your query. For example
you are trying to do
query.setParameter(parm1, new Long(parm1Value));
whereas, in query there is no parameter like parm1
i.e. query might be just from Item item
Or you might be committing some spelling mistake in your code
Eg. query.setParameter(‘pram1′, new Long(parm1Value));
and query is from Item item item.desc like :parm1
Do note that your parameter name in Java Class is misspelt as pram1 instead of parm1.


