简体   繁体   中英

Datanucleus GAE owned relationship not working

While migrating a project to the cloud sdk following the guide described at https://cloud.google.com/appengine/docs/standard/java/tools/migrate-maven I had to upgrade some DataNucleus dependencies, which seams to have caused a problem. DataNucleus does not load a unidirectional owned onetomany relationship correctly for data persisted pre-migration. Fetching the relationship returns null. The way the data is persisted seems to have changed somehow.

If I persist a new entity, a column is added to the table, which contains relationship information. Fetching one of these newly persisted entities, gives the correct result.

Is it possible to upgrade the DataNucleus versions without migrating the data? Is a specific annotation needed or something?

Jars used pre-migration:

  • datanucleus-jpa-1.1.5
  • datanucleus-core-1.1.5
  • datanucleus-appengine-1.0.10.final

Dependencies used now:

 <dependency> <groupId>org.datanucleus</groupId> <artifactId>datanucleus-core</artifactId> <version>3.1.3</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.datanucleus</groupId> <artifactId>datanucleus-api-jdo</artifactId> <version>3.1.3</version> </dependency> <dependency> <groupId>com.google.appengine.orm</groupId> <artifactId>datanucleus-appengine</artifactId> <version>2.1.2</version> </dependency> 

relationship code snippet:

@Persistent(defaultFetchGroup="true", dependentElement="true")
@Extension(vendorName="datanucleus", key="comparator-name", 
value="be.coco.shared.quantity.Quantity")
private SortedSet<Quantity> quantities = new TreeSet<Quantity>();

I found your issue in the Google Issue Tracker. The malfunctioning you are observing is most probably related to the compatibility issues of datanucleus-appengine. As it is stated in the answer in Google Issue Tracker:

(...), it is recommended to instead follow the appropriate DataNucleus specific Maven documentation for continued DataNucleus support.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM