0

I have implemented HibernateLoopDataSource in which I have constructor, one without applied criteria and one with. It looks like following

HibernateLoopDataSource.java

//code trimmed
HibernateLoopDataSource(Session hibernate, Class<?> typeOfClass){
  this.hibernate = hibernate;
  this.typeOfClass = typeOfClass;
}

HibernateLoopDataSource(Session hibernate, Class<?> typeOfClass, AppliedCriteria appliedCriteria){
  this.hibernate = hibernate;
  this.typeOfClass = typeOfClass;

}



AppliedCriteria.java //looks like following 

it is an interface and contains only one method

applyingCriteria(Criteria criteria);

and

GettingArticles.java

// code trimmed

public LoopDataSource getArticles(){
return new HibernateLoopDataSource(hibernate, Article.class, new AppliedCriteria(){
 public void applyingCriteria(Criteria criteria){
   criteria.add(Restrictions.eq("article.id", fullCommentPageListing.getArticle().getId()));}});}

However, when I try to initialize it doesn't report anything, however it loops without applying criteria. What may be the cause of this issue, I am stuck on it 2 hours, it may be some trivial, and I can't see it, 'cause I am working on this for 8 hours. Any help is appreciated.

1 Answer 1

1

You don't do anything with the criteria argument in the constructor:

HibernateLoopDataSource(Session hibernate, 
                        Class<?> typeOfClass, 
                        AppliedCriteria appliedCriteria){
    this.hibernate = hibernate;
    this.typeOfClass = typeOfClass;
    // you should have this.appliedCriteria = appliedCriteria here
}
Sign up to request clarification or add additional context in comments.

4 Comments

Yeah, probably a mistake from copy-pasting. Will check it now, if it works.
Just checked, nothing happens. Will have to look for Tomcat logs.
We don't know what a HibernateLoopDataSource might be. It's impossible to find a bug in some code without seeing the code.
I have just solved this by implementing additionalConstraintCallback bounding to the prepare() function. You couldn't call it anyway, 'cause it wasn't configured there. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.