generic query language


Performance and scalability: generic query language

  1. generic query language (3 messages)


    I'm totally newbie in java world, so after trying to build my first app. I've stuck with the problem of user-defined search queries.
    I use hibernate as ORM + DAO pattern. Users need to be able to perform search in database using simple combination of AND/OR predicates on objects's properties. I'd prefer not to fall into raw SQL but looking for something like "generic query language" wich I could convert into HQL, SQL or any kind of query language for particular ORM. Currently I'm playing with Predicates and Transformers from apache commons colections package, but can't see any simple way to convert predicate into other representation.

    I've searched for some related pattern but could not find anything appropriate. Any help would be greatly appreciated.

    Threaded Messages (3)

  2. generic query language[ Go to top ]

    using Hibernate, i suppose you´ve already seen the criteria-api ? using generic wrappers around this was our solution.
  3. generic query language[ Go to top ]

    Thats is what I've tried to make first - to write generic wrapper around criteria API. But then I thought that I'm trying to reinvent the weel.
    Thanks for reply.
  4. Quite hack'ish solution...[ Go to top ]

    Altought it's quite a hack, I use a Map<String,Object> filter object, and then I do

    filter.put("name__equal", name);
    filter.put("age__greaterThan", age);

    in my HibernateGenericDaoImpl<EId,EEntity> base class I have a method which decodes these and creates criteria-based queries.

    The only reason is making my higher level logic independent from hibernate's api.