Refactoring packages containing JDO @PersistenceCapable classes in the Google App Engine

I have a set of classes that support JDO compatibility in packages that need to be reorganized.

I know if you change the class name, then you need to update the "BigTables" objects. However, if I change the package to which java objects belong, will this mean that the data objects in BigTables need to be updated somehow?

those. com.example.test.Person β†’ com.example.blah.Person

+4
source share
2 answers

A little about this is documented in official documents under Object Fields and Object Properties . Here is the result in terms of refactoring rules:

  • Adding a new field with a null value to your class will cause all existing objects to have zero for this field.
  • Adding a new collection or array field will cause all existing objects to have an empty collection or array for this field.
  • Adding a new non-zero field will throw an exception when trying to load existing objects.
  • Deleting a field will not result in an error; existing objects retain the old field until they are loaded and saved again.
  • Changing the field type will cause App Engine to try to pass the old values ​​to the new data type; an exception will be thrown if the cast is invalid. The exception is numerical types; in this case, the value is converted, not converted, and overflow does not cause an exception.

If you need to do refactoring that cannot be achieved with simple modifications as described above, you probably want to use the mapreduce App Engine library .

+1
source

I assume the situation is this:

I have a class com.peter.Foo that I continue to use JDO and I want to change it to com.nick.Foo, will all my existing Foo objects be updated? In other words, does JDO use package names when mapping a java class to a data warehouse type?

AFAIK, JDO tools in appengine use only the class name. I will say this because when I look in the admin console, the statistics of the dataviewer and datastore refer to my entities only by class name. Therefore, if you keep the class names the same and change the package names, your objects should be in order.

+1
source

Source: https://habr.com/ru/post/1316254/


All Articles