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

issues on enums? #67

Open
georgemoralis opened this issue Jul 6, 2017 · 3 comments
Open

issues on enums? #67

georgemoralis opened this issue Jul 6, 2017 · 3 comments

Comments

@georgemoralis
Copy link

I have the following on my entity

private Integer eiditype;

public SpeciesType getEiditype() {
return SpeciesType.getType(this.eiditype);
}

public void setEiditype(SpeciesType eiditype) {

    if (eiditype == null) {
        this.eiditype = null;
    } else {
        this.eiditype = eiditype.getId();
    }
}

When i use the following query

stream = stream.where(p -> p.getEiditype() == SpeciesType.SERVICE);

i get the following error

Caused by: org.jinq.rebased.org.objectweb.asm.tree.analysis.AnalyzerException: Unknown method prototype/eidi/EidiEntity:getEiditype()LprototypeERP/model/enums/SpeciesType; encountered

I tried with ids as well

stream = stream.where(p -> p.getEiditype().getId() == SpeciesType.SERVICE.getId());

but not working either , any idea?

@georgemoralis
Copy link
Author

btw my whole enum implementation was based on that

http://blog.chris-ritchie.com/2013/09/mapping-enums-with-fixed-id-in-jpa.html

@my2iu
Copy link
Owner

my2iu commented Jul 7, 2017

I think in this case, JPA/Hibernate/EclipseLink sees the field as being an integer, not an enum. (The enum stuff in this situation is just a wrapper that the JPA layer doesn't see.) So Jinq expects the accessor method to return an integer as well. You would need to create a separate getter that uses an integer, and use that in your queries so that Jinq creates code that is consistent with what JPA/Hibernate/EclipseLink is expecting.

public int getEiditype() {
   return this.eiditype;
}

Jinq only supports enums when you use normal JPA enums

@georgemoralis
Copy link
Author

yah i changed it to proper jpa enum to handle it properly without 2 getters and now it appears to work right thank you for your efford and help!

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

No branches or pull requests

2 participants