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

Fieldgenerator yeilds ReferenceField instead of ComparableField #345

Closed
julgus opened this issue Jun 19, 2023 · 2 comments
Closed

Fieldgenerator yeilds ReferenceField instead of ComparableField #345

julgus opened this issue Jun 19, 2023 · 2 comments
Assignees
Labels
bug Something isn't working
Projects
Milestone

Comments

@julgus
Copy link
Member

julgus commented Jun 19, 2023

Describe the bug
The fieldgenerator uses an incorrect field type when building the JPAStreamer metamodel. This means that comparators such as .between() and .greaterThan() are unavailable when building predicates.

Expected behavior
A field with the following definition should generate a ComparableField:

@Column(name = "length", columnDefinition = "smallint(5)")
@NotEmpty(message = "Length may not be empty", groups = {GroupA.class})
@NotNull(message = "Length may not be null", groups = {GroupA.class, GroupB.class})
@Size(min = 1, max = 300, message = "Length must be between 1 and 300 minutes characters long")
private Integer length;

Should generate:

    /**
     * This Field corresponds to the {@link Film} field "length".
     */
    public static final ComparableField<Film, Integer> length = ComparableField.create(
        Film.class,
        "length",
        Film::getLength,
        false
    );

Actual behavior*
The field generates a ReferenceField:

    /**
     * This Field corresponds to the {@link Film} field "length".
     */
    public static final ReferenceField<Film, Integer> length = ReferenceField.create(
        Film.class,
        "length",
        Film::getLength,
        false
    );

How To Reproduce
Add one of the annotations @Size, @NotNull or @NotEmpty to a JPA field.

Build tool
Maven 3.9.0

JPAStreamer version
JPAStreamer 3.0.2

JPA Provider
Hibernate 6.0.2.Final

Java Version
11.0.17

@julgus julgus added the bug Something isn't working label Jun 19, 2023
@julgus julgus added this to the 3.0.3 milestone Jun 19, 2023
@julgus julgus self-assigned this Jun 19, 2023
@julgus julgus added this to Prio 1 in 3.0.4 Jun 19, 2023
@julgus julgus moved this from Prio 1 to In Progress in 3.0.4 Jun 20, 2023
@julgus
Copy link
Member Author

julgus commented Jun 20, 2023

The annotations are clearly disturbing how we are handling two different Integer fields:

image

For some reason, the annotations separate the package name java.lang from Integer. We probably just need to fix how we handle the parsing of type names.

@julgus
Copy link
Member Author

julgus commented Jun 20, 2023

Most interestingly this disturbance only occurs during Maven builds. During IntelliJ builds the annotations are followed by the qualified type name:

image

@julgus julgus moved this from In Progress to Done in 3.0.4 Jun 20, 2023
@julgus julgus closed this as completed in 8d384de Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
3.0.4
Done
Development

No branches or pull requests

1 participant