Results 1 to 4 of 4

Thread: Handling criteria without Hibernate dependancies?

  1. #1
    Join Date
    Aug 2004
    Location
    Columbus, OH, USA
    Posts
    133

    Default Handling criteria without Hibernate dependancies?

    I'm having a hard time wrapping my head around something. I'm sure this is easier than I think, but I'm having a major mental block.

    Let's say I have a "search" screen that allows a user to specify query criteria, like start and end date, project manager, city, state, etc. They can either leave the criteria wide open (wildcard) or specify values for a handful of fields.

    Currently my Struts actions handle this by looking at the specified values and passing them down to DAO methods which have (far too) many input parameters. These in turn build Hibernate Query or Critera objects and throw them against the database. It works fine, but the DAO method signatures are ugly. And I don't want to use the Hibernate Criteria objects above the DAO layer, because then I'd tie my service layer to a specific DAO implementation (Hibernate).

    How would you refactor this?

    Thanks in advance,
    Scott

  2. #2
    Join Date
    Aug 2004
    Location
    A Coruņa, Spain
    Posts
    17

    Default

    You can pass only an argument (e.g. the Hibernate business object) and create a criteria for those fields not null.

    That's what I do in a generic way (only a dao for all application) using Hibernate metadata.

    You can check it at http://oness.sourceforge.net in the oness-common-model module

    Regards

  3. #3
    Join Date
    Aug 2004
    Location
    Columbus, OH, USA
    Posts
    133

    Default

    That's interesting, but how would you represent value ranges using query by example (QbE) objects?

  4. #4
    Join Date
    Aug 2004
    Location
    A Coruņa, Spain
    Posts
    17

    Default

    I don't use ranges but maybe you could pass two values and check for not null values in the second, then it would be a range.

Similar Threads

  1. Replies: 2
    Last Post: Sep 20th, 2005, 12:59 AM
  2. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  3. How to use hibernate criteria API smartly
    By gaplo in forum Architecture
    Replies: 5
    Last Post: Jul 20th, 2005, 05:40 AM
  4. Replies: 8
    Last Post: Mar 23rd, 2005, 02:01 PM
  5. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •