Open kindywu opened 5 years ago
I would have to see the full stack trace to see what the error is. I suspect the problem is that Jinq can't determine the name of your boolean methods. When you use field-based annotations in JPA, Jinq has to guess the names of the getter methods. For the field "isReadyOnly", I think Jinq is guessing that the getter method is either "isIsReadyOnly" or "getIsReadOnly" but the actual getter method is "isReadOnly."
For this case, you will have to manually tell Jinq what the name of the getter method is
this.registerAssociationAttribute(
DictionaryCategory.class.getMethod("isReadOnly"), "isReadOnly", false));
You might have to do this on all the entities that inherit from BaseEntity
.
java.lang.IllegalArgumentException: Could not analyze lambda code
at org.jinq.jpa.transform.LambdaAnalysis.fullyAnalyzeLambda(LambdaAnalysis.java:197)
at org.jinq.jpa.transform.LambdaInfo.fullyAnalyze(LambdaInfo.java:116)
at org.jinq.jpa.JPAQueryComposer.applyTransformWithLambda(JPAQueryComposer.java:283)
at org.jinq.jpa.JPAQueryComposer.where(JPAQueryComposer.java:449)
at org.jinq.jpa.JPAQueryComposer.where(JPAQueryComposer.java:63)
at org.jinq.orm.stream.QueryJinqStream.where(QueryJinqStream.java:45)
at org.jinq.jpa.QueryJPAJinqStream.where(QueryJPAJinqStream.java:106)
at com.tencent.demo.services.DictionaryService.queryDictionaryCategory2(DictionaryService.java:46)
at com.tencent.demo.services.DictionaryService$$FastClassBySpringCGLIB$$9b9c0c64.invoke(
i try your way ,but it also throw the same exception @my2iu
protected JinqJPAStreamProvider streams;
@PersistenceUnit
public void setEntityManagerFactory(EntityManagerFactory emf) throws Exception {
streams = new JinqJPAStreamProvider(emf);
}
public void queryDictionaryCategory2() throws NoSuchMethodException, SecurityException {
//here @my2iu
streams.registerAssociationAttribute(DictionaryCategory.class.getMethod("isDeleted"), "isDeleted", false);
JPAJinqStream
You can see from the stack trace here that it doesn’t recognize the isDeleted() method:
Caused by: org.jinq.rebased.org.objectweb.asm.tree.analysis.AnalyzerException: Unknown method com/tencent/demo/model/dbs/DictionaryCategory:isDeleted()Z encountered
Manually registering it should allow Jinq to recognize the method. I’m not sure why it’s not working for you. Are you sure you’re registering on the same JinqJPAStreamProvider that you are calling the query on? You register isDeleted on “streams”, but you use “this” to create the query. Do they refer to the same object?
yes,i'am sure the same object.i copy them from difference file.the stream var is define in baseservice class,and use in the DictionaryService isDeleted is java convention
@my2iu the java code file is in the .zip Desktop.zip
I always get the convention wrong too. I think the official convention is that the variable is called deleted
and the getter is called isDeleted
.
Anyway, the problem is that when you call registerAssociationAttribute()
, Jinq actually ends up registering the method BaseEntity.isDeleted()
because that's where the method is defined. The method that is actually called is DictionaryCategory.isDeleted()
though, so that's where Jinq is getting confused. You have to use the alternate registration method:
streams.registerAssociationAttribute(DictionaryCategory.class.getMethod("isDeleted"), DictionaryCategory.class, "isDeleted", false);
ok,i get it,thanks
JPAJinqStream query = this.streamAll(DictionaryCategory.class);
List list = query.where(p.isDeleted() == true).toList();
failure[Could not analyze lambda code]
use the isReadOnly also occur the same error
@my2iu
jdk:1.8.0_181
springboot:2.1.0.RELEASE