Domanda

AppEnginge JAVA SetOrdering Funaction is not working

Messages.java

@PersistenceCapable
public class Messages{

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;

@Persistent
String name;

@Persistent
String Comments;

@Persistent
Date addedDate;

Query is

Query query = pm.newQuery(Messages.class);
query.setOrdering("addedDate desc");
List<Messages> results = (List<Messages>) query.execute();

also added indexing

<datastore-indexes autoGenerate="false">
<datastore-index kind="Messages" ancestor="true">
<property name="addedDate"  direction="desc" />
</datastore-index>

Result is not coming as expected.order by the addedDate.It results random data not ordered by addedDate Please Help?

È stato utile?

Soluzione

Remove the index definition for "Messages". You don't need to define an index on a single property.

Try without an index definition for Messages. You should get the correct results.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top