SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-886
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Shay Banon
Reporter: Richard King
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Compass

Improved Google App Engine JPA support

Created: 27/Jul/09 11:38 AM   Updated: 30/Jul/09 03:03 AM
Component/s: Compass::Gps
Affects Version/s: 2.3.0 beta1
Fix Version/s: None


 Description  « Hide
See thread here for more info : http://forum.compass-project.org/thread.jspa?threadID=216243&tstart=0

Essentially, the JPA queries need modifying such that they use the fully qualified class name of any entities and also aliases must be specified in the query (rather than implied), an example query format is

select x from com.whatever.Entity x

Effectively this fix only requires changes to DatanucleusJpaEntitiesLocator and EntityInformation as detailed in the post linked above.

For obvious reasons it is essential that when using JPA on AppEngine the SameThreadParallelIndexExecutor is used.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Shay Banon added a comment - 29/Jul/09 10:16 AM
In that same thread it was suggested that the new GAE version does support it. Maybe it makes sense to verify that this issue still applies to the latest GAE.

Richard King added a comment - 29/Jul/09 10:26 AM
I'm afraid the issue at least partly still applies. It may be that the fully qualified path name is no longer a requirement but the trailing 'x' still appears to be. I updated the thread with my tests on this, will feedback any more info I find.

Shay Banon added a comment - 29/Jul/09 12:33 PM
I have just committed a fix to add the trailing x in the DatanucleusJpaEntitiesLocator. I will kick a nightly build, can you give it a go?

Richard King added a comment - 30/Jul/09 02:14 AM
Good news! That seems to have done the trick CMPTRK-NIGHTLY-542 works fine in my local testing for indexing and searching using GAE/JPA without any further modification.

For the record this is the device configuration I'm using.

{{

compass = new CompassConfiguration()
.setConnection("gae://index")
.setSetting(
CompassEnvironment.ExecutorManager.EXECUTOR_MANAGER_TYPE,
"disabled").addScan("com.jelerang.koogaloo.entity")
.registerConverter("keyConverter",
com.google.appengine.api.datastore.Key.class,
(Converter) (new KeyConverter())).buildCompass();

compassGps = new SingleCompassGps(compass);

CompassGpsDevice device = new JpaGpsDevice("appengine", emfInstance);

((JpaGpsDevice) device)
.setParallelIndexExecutor(new SameThreadParallelIndexExecutor());

compassGps.addGpsDevice(device);

if(compass.getSearchEngineIndexManager().isLocked()){ compass.getSearchEngineIndexManager().releaseLocks(); }

compassGps.start();

//compassGps.index();

}}


Shay Banon added a comment - 30/Jul/09 02:17 AM
Great stuff!. Can you post your Key converter (I think you posted it in the forum somewhere)? I will add it as a built in feature in Compass...

Richard King added a comment - 30/Jul/09 03:03 AM
Sure, happy to be of help.

import org.compass.core.converter.ConversionException;
import org.compass.core.converter.basic.AbstractBasicConverter;
import org.compass.core.mapping.ResourcePropertyMapping;
import org.compass.core.marshall.MarshallingContext;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

/**

  • Compass converter for com.google.appengine.api.datastore.Key
    */
    public class KeyConverter extends AbstractBasicConverter<Key> {

@Override
protected Key doFromString(String keyString, ResourcePropertyMapping arg1,
MarshallingContext arg2) throws ConversionException { return KeyFactory.stringToKey(keyString); }

@Override
protected String doToString(Key key, ResourcePropertyMapping resourcePropertyMapping, MarshallingContext context){ return KeyFactory.keyToString(key); }

}


Richard King added a comment - 30/Jul/09 03:03 AM
(sorry about the formatting, got a bit messed up posting through jira)