I'm using the Google app engine and JDO. What is the best way to update a JDO class definition without having to wipe the data store contents first?
I'm not sure if this is specific to JDO on GAE, but I noticed that when I simply change the name of one of my persistent fields from svotes to votes, an exception is thrown (java.lang.NoSuchFieldError: svotes).
I expect once my site goes live I might want to make some changes to my JDO class definitions, such as adding a field or something. Any suggestions for how to update the data definitions without having to wipe the database?
Have you tried some of the methods mentioned here?
Apparently Google has a python related article about updating the schema: http://code.google.com/appengine/articles/update_schema.html. The guidelines can be applied to java too.
Related
I was told that one can generate CRUD operations directly form the database schema using app fuse. But I was unsuccessful in doing that using it and it look very long without any clue.
One possibility is to create the models and annotate it and create CRUDs and create database tables and also populate them with dummy variables. But is it possible to do it other way round.
I have been following this tutorial provided from App Fuse. Am I doing it wrong or is it possible.
Thanks
I would try using appfuse:gen-model:
http://static.appfuse.org/plugins/appfuse-maven-plugin/gen-model-mojo.html
Note, that AppFuse isn't great at creating relationships between classes, so you might have to do some work after it generates the code. You also might try searching the user mailing list archives:
http://appfuse.547863.n4.nabble.com/AppFuse-User-f547864.html
Fortunatly we have evolution in play framework 2 so we don't care about schema (if we want). My question is, is there any practice with loading data to the database on application startup? I suppose that I can load it with Global object, but what the approach needs less code and more flexible(in java)?
Take a look on the same question (and answer), the official way is showed in Zentasks sample.
you can also use common evolutions to insert data in raw SQL format (it doesn't work only with schema)
I have my most of my apps "dynamic" data stored in the datastore.
However, I also have a large collection of static data that would only change with new builds of the app. A series of flat files seems like it might be simpler than managing it in the datastore.
Are there standard solutions to this? How about libraries to make loading/parsing this content quick and easy? Does it make more sense to push this data to the datastore? Which would perform better?
Anyone else have this problem and have war stories they can share?
Everything depends on how you need to use the information.
I for instance have an application that needs to have a starting state provided from static data. Since I wanted this static data to be easily prepared outside the application, I put the data as spreadsheets on Google Docs and then I have an administrative function in my web app to load the starting state through Google Docs Spreadsheet API to objects in the datastore. It works fairly well, although there are some reliability issues that I haven't quite worked out yet (I sometimes need to restart the process).
In other cases, you might get away with just including the data as static property/xml files and load them through the standard Java resource APIs (getResourceAsStream and such). I haven't tried this approach though since it wasn't meaningful in my particular situation.
I have been working on an application using GAE in eclipse and I have a bunch of data objects. Sometimes I need to change their type, ie String -> Text so they can store more data.
What is the quickest easiest way to do a bulk update on the data/object store? I know I could probably write Java code to iterate over each object, but surely there is an easier way?
Normally there is no other way than iterating the store and changing the data by hand. The datastore is not otherwise accessible. However starting from version 1.3.3 of the SDK there is now the possibility to use SQLite as the datastore backend. To enable, set the flag --use_sqlite=true
You'll need then to find the SQLite file and should be able to use any SQLite client to manipulate the data.
UPDATE: As Nick Johnson noted, SQLite support is only available for the Python SDK and the data is encoded, making the task of directly editing the tables content rather difficult depending on the change. This invalidates this answer given the poster is looking for an easy, Java based solution :/
The best option for this is the newly released appengine-mapreduce library, which has both Java and Python versions.
In the case of converting from String to Text, though, there's no need to go through and update old entities manually - they'll be fixed when they're next written by your app, and will still work correctly in the meantime.
I have years of experience with Microsoft .NET development (primarily C#) and have been working to come up to speed on Android and Java. So far, I've built a small application with a couple screens and a working content provider.
All of the examples I've seen for developing content providers typically work with a single table, so I got the impression that this was the convention.
I built a couple more content providers for other tables and ran into the "Unknown URI" IllegalArgumentException when I tried to test them. The exception is being thrown by one of my content providers, but not the one I was intending to call.
It appears that my application is using the first content provider in the AndroidManifest.xml file, which now has me wondering if I should only have a single content provider for the entire application.
Are there any best practices and/or examples for working with multiple tables in an Android application? Should I have one content provider per table or only one for the entire application? If the former, how do I resolve URIs to the proper provider? If the latter, how do I keep my content provider code from being polluted with switch statements?
Well i have to disagree with CommonsWare.
If you want to avoid IllegalStateExceptions and other problems you need to use Cursorloader. They handle multiple things for you and make sure cursors are slick.
Therefore you need Content Providers.
The initial question is not answered yet thought. i don't know whats best practise for the number or content providers & tables. but within the .query method you check the URI id. you can test if the uri id has a specific value and build your query that way.
99% of Android applications do not need content providers.
Content providers have one primary use: inter-process communication. If you are:
expecting other developers to access your content providers, or
are integrating to Android in places that require a content provider (e.g., search suggestions for the Quick Search Box)
then, and only then, do you implement a content provider.
Otherwise, all you are doing is adding overhead to your application and making your code more difficult to maintain.
So, if your application is one of the 99% that does not need content providers, just get rid of the one you have and access your content by some other means (e.g., SQLiteDatabase).