surinder-insonix / datanucleus-appengine

Automatically exported from code.google.com/p/datanucleus-appengine
0 stars 0 forks source link

schema migration: can't read a String property into a Text field #212

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. create a JDO entity with a String property and save it to the datastore
2. edit the code to change the String to Text
3. run some code that loads the entity in a query

What is the expected output? What do you see instead?

I was hoping that a String stored in an Entity would automatically be converted 
to Text when it's loaded, but unfortunately this results in an exception. 
Here's a partial stack trace:

Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to 
com.google.appengine.api.datastore.Text
 at [redacted].jdoReplaceField(AbstractAllocation.java)
 at [redacted].jdoReplaceField(Allocation.java)
 at [redacted].jdoReplaceFields(VersionEntity.java)
 at org.datanucleus.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2772)
    at org.datanucleus.state.JDOStateManagerImpl.replaceFields(JDOStateManagerImpl.java:2791)
    at org.datanucleus.store.appengine.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:466)
    at org.datanucleus.store.appengine.query.DatastoreQuery.entityToPojo(DatastoreQuery.java:565)
    at org.datanucleus.store.appengine.query.DatastoreQuery.entityToPojo(DatastoreQuery.java:520)

What version of the product are you using? On what operating system?

1.0.6

Please provide any additional information below.

Original issue reported on code.google.com by skybr...@google.com on 1 Jul 2010 at 1:14

GoogleCodeExporter commented 8 years ago
I'm facing the same issue and using gae sdk 1.3.7 & gae-struts-0.1.

Original comment by nighteb...@gmail.com on 20 Sep 2010 at 2:54

GoogleCodeExporter commented 8 years ago
Delete all the Entity record in datastore , and then add new entity again. That 
will resolve this problem.

Original comment by nighteb...@gmail.com on 20 Oct 2010 at 2:16

GoogleCodeExporter commented 8 years ago
But then you lose your data.

Original comment by skybr...@google.com on 20 Oct 2010 at 2:37

GoogleCodeExporter commented 8 years ago
Same here. I'm using gae sdk 1.3.8. Is it gonna be fixed soon?

Original comment by hiepd...@google.com on 24 Nov 2010 at 5:11

GoogleCodeExporter commented 8 years ago
Schema migration is a big concern for any large evolving application. I'm 
looking at building apps on GAE but it seems that only low-level JDO tools 
allow for any kind of schema migration.

Is there a good way to do this?

Original comment by kurofune...@gmail.com on 26 Nov 2010 at 5:02

GoogleCodeExporter commented 8 years ago
Since the underlying datastore is not storing these with types, can't the code 
that loads it do the conversion?

Thanks,
Bob

Original comment by bobev...@google.com on 17 Mar 2011 at 11:51

GoogleCodeExporter commented 8 years ago
SVN trunk allows conversions from DB "String" -> Pojo "Text". I'd guess that 
this will work for schema evolution since it will load up the existing data 
(into a Text), and then when that object is updated should write the property 
as a Text (rather than String). Left as an exercise for the user to check it

Any other conversions have to be added explicitly, so raise separate issues for 
any other common ones (though it has most numeric conversions since v1).

Original comment by googleco...@yahoo.co.uk on 17 Jul 2011 at 3:38