If I create an owned one-to-many relationship with Google App Engine as the database, using the default Long as the primary key, I get the following error:
However, I’ve come up with a solution to get owned one-to-many to work using the Key as Encoded String strategy. The first thing I did was set the entity IDs to be a String. Here is my script:Code:Cannot have a java.lang.Long primary key and be a child object
Then I created an aspect to add the extension for encoded string to the entity id and an auto incrementing Long.Code:persistence setup --provider DATANUCLEUS --database GOOGLE_APP_ENGINE entity --class ~.server.domain.Person --identifierType java.lang.String field string --fieldName firstName field string --fieldName lastName entity --class ~.server.domain.Address --identifierType java.lang.String field string --fieldName streetAddress field string --fieldName city field string --fieldName state --permitReservedWords field string --fieldName zip field reference --fieldName person --type Person focus --class Person field set --fieldName addresses --element Address --cardinality ONE_TO_MANY --mappedBy person gwt setup
Code:package com.test.server.domain; import org.datanucleus.jpa.annotations.Extension; privileged aspect Person_Roo_GAE { declare @field: * Person.id: @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true"); @Extension(vendorName="datanucleus", key="gae.pk-id", value="true") private Long Person.autoId; public Long Person.getAutoId() { return this.autoId; } public void Person.setAutoId(Long autoId) { this.autoId = autoId; } }And with that minor mod, the scaffold works perfectly with GAE.Code:package com.test.server.domain; import org.datanucleus.jpa.annotations.Extension; privileged aspect Address_Roo_GAE { declare @field: * Address.id: @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true"); @Extension(vendorName="datanucleus", key="gae.pk-id", value="true") private Long Address.autoId; public Long Address.getAutoId() { return this.autoId; } public void Address.setAutoId(Long autoId) { this.autoId= autoId; } }


Reply With Quote
)