google-code-export / twig-persist

Automatically exported from code.google.com/p/twig-persist
1 stars 1 forks source link

Cannot load object with blob with GAE SDK 1.7.5 #80

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I moved to GAE SDK 1.7.5 with Java 7
My object contains a blob:
    private @Parent User user;
    private boolean shown = false;
    private @Type(Blob.class) LogRecord logline;
    private long millis;

The previously deployed version based on GAE 1.7.4 can read the objects. The 
new one fails with this stack trace:

Caused by: java.lang.IllegalArgumentException: Cannot compare [SimpleProperty 
value=<Blob: 366 bytes> path=logline indexed=false]
    at com.vercer.engine.persist.util.SimpleProperty.compareTo(SimpleProperty.java:111)
    at com.vercer.engine.persist.util.SimpleProperty.compareTo(SimpleProperty.java:7)
    at java.util.TreeMap.compare(TreeMap.java:1188)
    at java.util.TreeMap.put(TreeMap.java:531)
    at java.util.TreeSet.add(TreeSet.java:255)
    at java.util.AbstractCollection.addAll(AbstractCollection.java:334)
    at java.util.TreeSet.addAll(TreeSet.java:312)
    at java.util.TreeSet.<init>(TreeSet.java:160)
    at com.vercer.engine.persist.standard.AbstractStatelessObjectDatastore.toTypesafe(AbstractStatelessObjectDatastore.java:270)
    at com.vercer.engine.persist.standard.StrategyObjectDatastore.toTypesafe(StrategyObjectDatastore.java:504)
    at com.vercer.engine.persist.standard.StandardTypedFindCommand$EntityToInstanceFunction.apply(StandardTypedFindCommand.java:572)
    at com.vercer.engine.persist.standard.StandardTypedFindCommand$EntityToInstanceFunction.apply(StandardTypedFindCommand.java:560)
    at com.google.common.collect.Iterators$8.next(Iterators.java:812)
    at com.google.common.collect.ForwardingIterator.next(ForwardingIterator.java:48)

I'd be happy to provide more information.

What version of the product are you using? On what operating system?
GAE SDK 1.7.5
twig-persist 1.0.4 (the only one available in the maven repository; hints on 
using 2.0-rc with maven?)

Original issue reported on code.google.com by alex.rho...@temet.ch on 16 Mar 2013 at 6:02

GoogleCodeExporter commented 9 years ago
Apparently, the trouble starts with this line in 
java.util.TreeMap.put(TreeMap.java:531)
            compare(key, key); // type (and possibly null) check
com.vercer.engine.persist.util.SimpleProperty.compareTo is not prepared to 
compare a blob with itself. Maybe, the method should start with
 if(this == o)
    return 0;

Original comment by alex.rho...@temet.ch on 16 Mar 2013 at 6:15

GoogleCodeExporter commented 9 years ago
or, as everything thinkable is in the equals() method
if(equals(o))
 return 0;

The method in twig 2.0 RC should also work, as value==o.getValue() should be 
true if this==o
How can I get 2.0 with maven?

Original comment by alex.rho...@temet.ch on 16 Mar 2013 at 6:32

GoogleCodeExporter commented 9 years ago
Ah yes this bug was fixed in the repo.  Have you tried the latest download?  
You can build the jaar yourself using these instructions 
https://code.google.com/p/twig-persist/wiki/Integration2_0

Original comment by jdpatterson on 17 Mar 2013 at 9:59

GoogleCodeExporter commented 9 years ago
The ObjectDatastore.store(object, parent) method is now
ObjectDatastore.store().instance(object).parent(parent).now()?

Can I replace @Key directly with @Id?

Original comment by alex.rho...@temet.ch on 17 Mar 2013 at 9:29

GoogleCodeExporter commented 9 years ago
Yes, it is now @Id in 2.0 because the long value is only one part of the full 
Key.  Eventually @Key will probably be used for what is now @GaeKey

Original comment by jdpatterson on 17 Mar 2013 at 9:35