Announcement Announcement Module
Collapse
No announcement yet.
Handling criteria without Hibernate dependancies? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


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

      Comment


      • #4
        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.

        Comment

        Working...
        X