[appengine-java] Re: SQL Like operator with %

2010-07-07 Thread Julian!
Hi There

searchWords is a List of User entity that contains All tokens?

the filter in de JDOQL  WHERE searchWords == \+tag.toUpperCase()+.
find some token in all elements on the List property ???


Thanks !!


On 2 jul, 06:49, RAVINDER MAAN rsmaan...@gmail.com wrote:
 we can set it in following way

   public class User {

 @Persistent(defaultFetchGroup=true)
 private SetString searchWords;

 public static void getCombination(String word,Set searchWords){
 word = word.trim().toUpperCase();
 if(word == null || .equals(word))
 return ;
 int wordLength = word.length();
 while(true){
 for(int i=0;iwordLength - 2;i++){
 searchWords.add(word.substring(i, wordLength));}

 for(int i=wordLength-1;i  1;i--){
 searchWords.add(word.substring(0, i));}

 word = word.substring(1,wordLength-1);
 wordLength = word.length();
 if(wordLength = 2)
 break;
 else
 searchWords.add(word);}
 return ;
 }

 public ListUser search(String tag){
 PersistenceManager pm = PMF.getPM();
 Transaction tx=pm.currentTransaction();
 try
 {
  tx.begin();

     Query q = pm.newQuery(javax.jdo.query.JDOQL,SELECT FROM
 +User.class.getName()+ WHERE searchWords == \+tag.toUpperCase()+\);
     q.setRange(0,10);
     ListUser c = (ListUser)q.execute();
     tx.commit();
     return c;}

 finally
 {
     if (tx.isActive())
     {
         tx.rollback();
     }

     pm.close();}

  }

 }

 You can modify getCombination the way you want.

 --

 Regards,
 Ravinder Singh Maan

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: SQL Like operator with %

2010-07-07 Thread RAVINDER MAAN
searchWords is list of strings.

On Wed, Jul 7, 2010 at 4:38 AM, Julian! julia...@gmail.com wrote:

 Hi There

 searchWords is a List of User entity that contains All tokens?

 the filter in de JDOQL  WHERE searchWords == \+tag.toUpperCase()+.
 find some token in all elements on the List property ???


 Thanks !!


 On 2 jul, 06:49, RAVINDER MAAN rsmaan...@gmail.com wrote:
  we can set it in following way
 
public class User {
 
  @Persistent(defaultFetchGroup=true)
  private SetString searchWords;
 
  public static void getCombination(String word,Set searchWords){
  word = word.trim().toUpperCase();
  if(word == null || .equals(word))
  return ;
  int wordLength = word.length();
  while(true){
  for(int i=0;iwordLength - 2;i++){
  searchWords.add(word.substring(i, wordLength));}
 
  for(int i=wordLength-1;i  1;i--){
  searchWords.add(word.substring(0, i));}
 
  word = word.substring(1,wordLength-1);
  wordLength = word.length();
  if(wordLength = 2)
  break;
  else
  searchWords.add(word);}
  return ;
  }
 
  public ListUser search(String tag){
  PersistenceManager pm = PMF.getPM();
  Transaction tx=pm.currentTransaction();
  try
  {
   tx.begin();
 
  Query q = pm.newQuery(javax.jdo.query.JDOQL,SELECT FROM
  +User.class.getName()+ WHERE searchWords ==
 \+tag.toUpperCase()+\);
  q.setRange(0,10);
  ListUser c = (ListUser)q.execute();
  tx.commit();
  return c;}
 
  finally
  {
  if (tx.isActive())
  {
  tx.rollback();
  }
 
  pm.close();}
 
   }
 
  }
 
  You can modify getCombination the way you want.
 
  --
 
  Regards,
  Ravinder Singh Maan

 --
 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
 google-appengine-j...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.




-- 
Regards,
Ravinder Singh Maan

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: SQL Like operator with %

2010-07-05 Thread Khor Yong Hao
Why not directly use String.contains(searchstring) method?

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: SQL Like operator with %

2010-07-05 Thread RAVINDER MAAN
You mean retrieve all entities and then use contains method?


On Mon, Jul 5, 2010 at 8:29 AM, Khor Yong Hao fyh...@gmail.com wrote:

 Why not directly use String.contains(searchstring) method?

 --
 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
 google-appengine-j...@googlegroups.com.
 To unsubscribe from this group, send email to
 google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/google-appengine-java?hl=en.




-- 
Regards,
Ravinder Singh Maan

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: SQL Like operator with %

2010-07-04 Thread Steve Osborne
That will work. Thank you very much Ravinder.

On Jul 2, 7:49 am, RAVINDER MAAN rsmaan...@gmail.com wrote:
 we can set it in following way

   public class User {

 @Persistent(defaultFetchGroup=true)
 private SetString searchWords;

 public static void getCombination(String word,Set searchWords){
 word = word.trim().toUpperCase();
 if(word == null || .equals(word))
 return ;
 int wordLength = word.length();
 while(true){
 for(int i=0;iwordLength - 2;i++){
 searchWords.add(word.substring(i, wordLength));}

 for(int i=wordLength-1;i  1;i--){
 searchWords.add(word.substring(0, i));}

 word = word.substring(1,wordLength-1);
 wordLength = word.length();
 if(wordLength = 2)
 break;
 else
 searchWords.add(word);}
 return ;
 }

 public ListUser search(String tag){
 PersistenceManager pm = PMF.getPM();
 Transaction tx=pm.currentTransaction();
 try
 {
  tx.begin();

     Query q = pm.newQuery(javax.jdo.query.JDOQL,SELECT FROM
 +User.class.getName()+ WHERE searchWords == \+tag.toUpperCase()+\);
     q.setRange(0,10);
     ListUser c = (ListUser)q.execute();
     tx.commit();
     return c;}

 finally
 {
     if (tx.isActive())
     {
         tx.rollback();
     }

     pm.close();}

  }

 }

 You can modify getCombination the way you want.

 --

 Regards,
 Ravinder Singh Maan

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: SQL Like operator with %

2010-07-02 Thread Steve Osborne
Could you give an example of tokenized string with the List property?

On Jun 15, 8:03 pm, Ikai L (Google) ika...@google.com wrote:
 The datastore doesn't provide LIKE queries. One thing you can do is tokenize
 the String, store each token as part of a List property, then check against
 the List property - but this doesn't solve your case of substring search.





 On Thu, Jun 10, 2010 at 6:35 AM, RAVINDER MAAN rsmaan...@gmail.com wrote:
  Hello all
    how we can we implement SQL like operator in java JDO query. how
  can I write this query in JDO

  select * from employee where name like '%james%';
  Employee is entity with property name.

  --
  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
  google-appengine-j...@googlegroups.com.
  To unsubscribe from this group, send email to
  google-appengine-java+unsubscr...@googlegroups.comgoogle-appengine-java%2b­unsubscr...@googlegroups.com
  .
  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
 Blog:http://googleappengine.blogspot.com
 Twitter:http://twitter.com/app_engine
 Reddit:http://www.reddit.com/r/appengine- Hide quoted text -

 - Show quoted text -

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



Re: [appengine-java] Re: SQL Like operator with %

2010-07-02 Thread RAVINDER MAAN
we can set it in following way

  public class User {

@Persistent(defaultFetchGroup=true)
private SetString searchWords;

public static void getCombination(String word,Set searchWords){
word = word.trim().toUpperCase();
if(word == null || .equals(word))
return ;
int wordLength = word.length();
while(true){
for(int i=0;iwordLength - 2;i++){
searchWords.add(word.substring(i, wordLength));
}
for(int i=wordLength-1;i  1;i--){
searchWords.add(word.substring(0, i));
}
word = word.substring(1,wordLength-1);
wordLength = word.length();
if(wordLength = 2)
break;
else
searchWords.add(word);
}
return ;
}
public ListUser search(String tag){
PersistenceManager pm = PMF.getPM();
Transaction tx=pm.currentTransaction();
try
{
 tx.begin();

Query q = pm.newQuery(javax.jdo.query.JDOQL,SELECT FROM
+User.class.getName()+ WHERE searchWords == \+tag.toUpperCase()+\);
q.setRange(0,10);
ListUser c = (ListUser)q.execute();
tx.commit();
return c;
}
finally
{
if (tx.isActive())
{
tx.rollback();
}


pm.close();
}
 }

}

You can modify getCombination the way you want.


-- 

Regards,
Ravinder Singh Maan

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.