#1 Create a query with an "IN" clause

closed
nobody
None
5
2007-03-26
2006-02-02
Sacker
No

Is there any way to execute an "IN" clause in a query
with pbeans? I am using mySQL for my database.

What I want is to pull any records where status has one
of several values, so the query I'm looking for is
"select * from forum where status in ('A','B','C','D','E')"

I tried building a String that contained
"('A','B','C','D','E')" and then, using Criteria, I did
the following:

criteria.put("status", valuesList, new SimpleOperator("
IN "));

However, pbeans reformatted the valuesList so that it
caused a mySQL error (it puts tics around the whole
string and escapes the ticks around the values). So,
clearly SimpleOperator wasn't meant to provide "IN"
clauses.

Any other thoughts?

By the way, I love pbeans!!! I'm a decent OO
programmer, but I *hate* ORM stuff. pbeans has been a
life saver in creating my current project. Thanks for
providing it!

William

Discussion

  • Jose Solorzano

    Jose Solorzano - 2007-03-26
    • status: open --> closed
     
  • Jose Solorzano

    Jose Solorzano - 2007-03-26

    Logged In: YES
    user_id=33204
    Originator: NO

    pBeans 2.0 allows arbitrary queries. That should take care of it. There's also a Criteria functionality that could easily be extended with an IN operator I believe.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks