Search code examples
jpainheritanceentitycriteria

EasyCriteria: We could not find the parameter: creationDate in the given class Assignment


So, I'm making a EasyCriteria-query.

I have a mapped superclass:

@MappedSuperclass
public abstract class CreatedEntity extends IdEntity implements Creatable {

    private static final long serialVersionUID = 1L;

    @ManyToOne
    @JoinColumn(name="fk_creation_userid")
    protected UserId creationUserId;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name="creation_date")
    protected Date creationDate;

Then I have a subclass that makes an EasyCriteria query:

@Entity
@Table(name = "assignment")
public class Assignment extends CreatedEntity {

final EasyCriteria<Assignment> ec = easyCriteria(Assignment.class);

            ec.setDistinctTrue();

...

UserId assignmentGiver = searchTerms.getAssignmentGiver();
        if (assignmentGiver != null) {
            ec.andEquals("creationUserId", assignmentGiver);
        }

Date startDate = searchTerms.getStartDate();
        if (startDate != null) {
            ec.andGreaterOrEqualTo("creationDate", startDate);
        }

Now, the creationUserId search works but EasyCriteria claims that the superclass doesn't have creationDate property, even though it does. The creationUserId query works perfectly and it is a property from the exactly same superclass.

The Exception I get is:

We could not find the parameter: creationDate in the given class: class ...[path]...Assignment

What is wrong? I've spent nearly two days trying to solve this.

Additional points of interest:

  • The ec.andGreaterOrEqualTo... comparison works if I choose another Date attribute from the subclass itself.
  • If I change the method to "ec.andEquals(..." it finds the field creationDate from the superclass.

So why that andGreaterOrEqualTo-method can't be used with a Date property mapped in the superclass?


Solution

  • Okay I updated EasyCriteria 3.0.0 to UaiCriteria 4.0.0 (name changed for legal reasons) and that fixed the problem. Remember to make sure that you don't have the old dependency remaining in Maven dependencies even after removing it from pom.xml and adding the new dependency there.

    I'm using Eclipse m2 plugin. I had to go and remove it by right clicking the old .jar in Project Explorer: Maven -> Exclude Maven artifact.

    I also added imports automatically in each class that use UaiCriteria, after that.