Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Entity View metamodel classes for views with attribute filters on primitive types can't be compiled #1826

Open
Seregy opened this issue Nov 14, 2023 · 0 comments

Comments

@Seregy
Copy link

Seregy commented Nov 14, 2023

Description

Entity View processor generates static metamodels that can't be compiled if an entity view declares default attribute filters for attributes with primitive types.
Entity view with an attribute filter:

@EntityView(Cat.class)
public interface CatSimpleView {
  // (...)
  @AttributeFilter(EqualFilter.class)
  int getPriority();
}

Expected behavior

Generated classes for an entity view with a default attribute filter for a primitive attribute can be compiled.

Actual behavior

Generated classes attempt to use a primitive type in the parametrized AttributeFilterMapping.
Actually generated metamodel:

@Generated(value = "com.blazebit.persistence.view.processor.EntityViewAnnotationProcessor")
@StaticMetamodel(CatSimpleView.class)
public abstract class CatSimpleView_ {
    // (...)
    public static volatile AttributeFilterMapping<CatSimpleView, int> priority_filter;
    // (...)
}

Changing the attribute type to a wrapper or declaring a custom filter with a wrapper type resolves the issue.

public class CustomBooleanEqualFilter extends EqualFilter<Boolean> {
}

// (...)

@EntityView(Cat.class)
public interface CatSimpleView {
  // (...)
  @AttributeFilter(CustomBooleanEqualFilter.class) // This works
  boolean isActive();
  // (...)
}

Steps to reproduce

Declare an entity view with an attribute of a primitive type and add one of the default attribute filters(like EqualFilter or GreaterThanFilter) via @AttributeFilter. Then try to generate metamodel classes.

See https://github.com/Seregy/blaze-entity-view-metamodel-primitive for an example in the project.

Environment

Version: 1.6.10 / 1.6.7
JPA-Provider: Hibernate 5.6.15.Final
DBMS: -
Application Server: Java SE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants