Does this cause a "needs index" error? What this means is that you'll need
to run the query locally, create an indexes file, then update the
application so App Engine can build your indexes. Read more about this here:

http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html

On a side note, you are creating a LOT of indexed properties. This'll
increase your entity write time, as indexes are updated synchronously, not
to mention take up a lot of datastore space.
<http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html>

On Wed, Feb 3, 2010 at 6:58 PM, yohan <[email protected]> wrote:

> Hi All,
>
> I got the problem when using the 'Order By' when querying the data,
> but if I remove the 'ORDER BY' it will ok.
> this is the code that caused the DataStoreNeedException error,
>
> StringBuffer sql = new StringBuffer();
> sql.append("select from com.adlink.table.TbMapBanner where")
>    .append(" map_type=='" + Constant.bannerWebsiteType + "'")
>    .append(" && map_type_id==" + currentWebsite.getWebsite_id())
>    .append(" && map_size_name=='"+ tbSize.getSize_name() +"'")
>    .append(" && (      map_geo=='GLOBAL' " +
>                                " || map_geo=='" + geoCode.getRegionCode() +
> "' " +
>                                " || map_geo=='" + geoCode.getCountryCode()+
> "' " +
>                                " || map_geo=='" + geoCode.getStateCode()+
> "') ")
>     .append(" && map_banner_approved==51");
>     .append(" && map_ratio>=0")
>     .append(" order by map_ratio DESC")
>     .append(" range 0,1");
>
> And the Index is:
> map_type ▲ , map_type_id ▲ , map_size_name ▲ , map_geo_type ▲ ,
> map_geo ▲ , map_account_email ▲ , map_banner_approved ▲ , map_ratio ▼
>
> And for the TbMapBanner code is:
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> public class TbMapBanner implements Serializable
> {
>        private static final long serialVersionUID = -8895557243942778257L;
>
>        @PrimaryKey
>       @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>        private Long map_id;
>
>        @Persistent
>        private String map_banner_id;
>
>        @Persistent
>        private String map_size_name;
>
>        @Persistent
>        private String map_type;
>
>        @Persistent
>        private long map_type_id;
>
>        @Persistent
>        private int map_geo_type;
>
>        @Persistent
>        private String map_geo;
>
>        @Persistent
>        private long map_click_count;
>
>        @Persistent
>        private long map_impression_count;
>
>        @Persistent
>        private float map_clickimpratio;
>
>        @Persistent
>        private float map_ratio;
>
>        @Persistent
>        private float map_bid_price;
>
>        @Persistent
>        private int map_sub_map_id;
>
>        @Persistent
>        private int map_banner_approved;
>
>        @Persistent
>        private String map_account_email;
>
>
>        public String getMap_account_email() {
>                return map_account_email;
>        }
>
>        public void setMap_account_email(String map_account_email) {
>                this.map_account_email = map_account_email;
>        }
>
>        public float getMap_ratio() {
>                return map_ratio;
>        }
>
>        public void setMap_ratio(/*float map_ratio*/) {
>                //this.map_ratio = map_ratio;
>                this.map_ratio = (map_bid_price/map_clickimpratio);
>        }
>
>        public Long getMap_id() {
>                return map_id;
>        }
>
>        public void setMap_id(Long map_id) {
>                this.map_id = map_id;
>        }
>
>        public String getMap_banner_id() {
>                return map_banner_id;
>        }
>
>        public void setMap_banner_id(String map_banner_id) {
>                this.map_banner_id = map_banner_id;
>        }
>
>        public String getMap_size_name() {
>                return map_size_name;
>        }
>
>        public void setMap_size_name(String map_size_name) {
>                this.map_size_name = map_size_name;
>        }
>
>        public int getMap_banner_approved() {
>                return map_banner_approved;
>        }
>
>        public void setMap_banner_approved(int map_banner_approved) {
>                this.map_banner_approved = map_banner_approved;
>        }
>
>        public String getMap_type() {
>                return map_type;
>        }
>
>        public void setMap_type(String map_type) {
>                this.map_type = map_type;
>        }
>
>        public long getMap_type_id() {
>                return map_type_id;
>        }
>
>        public void setMap_type_id(long map_type_id) {
>                this.map_type_id = map_type_id;
>        }
>
>        public int getMap_geo_type() {
>                return map_geo_type;
>        }
>
>        public void setMap_geo_type(int map_geo_type) {
>                this.map_geo_type = map_geo_type;
>        }
>
>        public String getMap_geo() {
>                return map_geo;
>        }
>
>        public void setMap_geo(String map_geo) {
>                this.map_geo = map_geo;
>        }
>
>        public long getMap_click_count() {
>                return map_click_count;
>        }
>
>        public void setMap_click_count(long map_click_count) {
>                this.map_click_count = map_click_count;
>        }
>
>        public long getMap_impression_count() {
>                return map_impression_count;
>        }
>
>        public void setMap_impression_count(long map_impression_count) {
>                this.map_impression_count = map_impression_count;
>        }
>
>        public float getMap_clickimpratio() {
>                return map_clickimpratio;
>        }
>
>        public void setMap_clickimpratio(float map_clickimpratio) {
>                this.map_clickimpratio = map_clickimpratio;
>        }
>
>        public float getMap_bid_price() {
>                return map_bid_price;
>        }
>
>        public void setMap_bid_price(float map_bid_price) {
>                this.map_bid_price = map_bid_price;
>        }
>
>        public int getMap_sub_map_id() {
>                return map_sub_map_id;
>        }
>
>        public void setMap_sub_map_id(int map_sub_map_id) {
>                this.map_sub_map_id = map_sub_map_id;
>        }
> }
>
> anyone can help me, please ?
>
>
> Thank's
>
> Yohan
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine
http://googleappengine.blogspot.com | http://twitter.com/app_engine

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to