-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Is it better to do complex logic to filter out results?
PostPosted: Wed Jan 19, 2005 4:09 am 
Senior
Senior

Joined: Sun Oct 26, 2003 5:05 am
Posts: 139
I guess this is a general database question, but I hope someone can answer it as it's more of a design question.

Is it better for complex cases to just get a List of results and then filter them out using Java instead of trying to query it out exactly out of the database?

I have a complex case where I need to analyze several variables, all with varying values, to determine if it should be in the list or not. I'm not saying getting rid of all the where clauses - I don't want all the rows. I'm just saying that I may get back a 100 or so rows, and with code, I will probably reduce it to 50 (or maybe not if all the results follow the complex condition).

When I say complex logic, I mean something that could take several nested conditions where it reflects on 3 or more variables to determine a state.

Which leads me to my next question: should I just store the calculated state to the database and re-calculate it whenever one of the important variables change? This would lead to a nice query where I can go "state = 'MYSTATE'" in the where clause.

I guess the problem with the above is that the state isn't part of the domain model. It's not something the business really deals in, but ironically I need to calculate it anyway for this problem. It's really a problem where the people who designed how the business worked didn't exactly create good business rules, so I have to analyze a gazillion different things to determine the state. I usually need to query based on this state, but because of how complex the logic is, the queries I'm trying out are returning duplicates and aren't working as I had hoped. It's just not something SQL is good for I don't think.

I'd like for you to give your thoughts on this. Thank you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.