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

Fixing hibernate tests + nested plural associations + making the JpaVisitorTest run against both hibernate and eclispelink #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ivelkov
Copy link

@ivelkov ivelkov commented Aug 15, 2017

Hello,

I'll try to summarize the changes bellow.

Tests

Previously the JpaVisitorTest was using only EclipseLink JPA and Hibernate was commented in the persistence.xml. As a result tests were failing when using Hibernate but passing when using EclipseLink.

With the proposed change, JpaVisitorTest is testing both Hibernate and EclipseLink.

Fixed Hibernate tests

With the previous version of the com.github.tennaito.rsql.jpa.PredicateBuilder, some JpaVisitorTest test cases were failing with the exception pasted bellow.

java.lang.ClassCastException: org.hibernate.jpa.criteria.path.SingularAttributePath cannot be cast to javax.persistence.criteria.From

	at com.github.tennaito.rsql.jpa.PredicateBuilder.findPropertyPath(PredicateBuilder.java:219)
	at com.github.tennaito.rsql.jpa.PredicateBuilder.createPredicate(PredicateBuilder.java:165)
	at com.github.tennaito.rsql.jpa.JpaPredicateVisitor.visit(JpaPredicateVisitor.java:99)
	at com.github.tennaito.rsql.jpa.JpaCriteriaQueryVisitor.visit(JpaCriteriaQueryVisitor.java:100)
	at com.github.tennaito.rsql.jpa.JpaCriteriaQueryVisitor.visit(JpaCriteriaQueryVisitor.java:47)
	at cz.jirutka.rsql.parser.ast.ComparisonNode.accept(ComparisonNode.java:70)
	at com.github.tennaito.rsql.jpa.JpaVisitorTest.testLessThanNotComparable(JpaVisitorTest.java:339)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:24)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Nested plural selections

Due to the same root cause "nested plural associations" were failing with

java.lang.IllegalStateException: Illegal attempt to dereference path source [null.tags] of basic type

	at org.hibernate.query.criteria.internal.path.AbstractPathImpl.illegalDereference(AbstractPathImpl.java:82)
	at org.hibernate.query.criteria.internal.path.AbstractPathImpl.get(AbstractPathImpl.java:174)
	at com.github.tennaito.rsql.jpa.PredicateBuilder.findPropertyPath(PredicateBuilder.java:223)
	at com.github.tennaito.rsql.jpa.PredicateBuilder.createPredicate(PredicateBuilder.java:165)
	at com.github.tennaito.rsql.jpa.JpaPredicateVisitor.visit(JpaPredicateVisitor.java:99)
	at com.github.tennaito.rsql.jpa.JpaPredicateVisitor.visit(JpaPredicateVisitor.java:47)
	at cz.jirutka.rsql.parser.ast.ComparisonNode.accept(ComparisonNode.java:70)

I've illustrated the problem with the Department -> ObjTags -> Tags association and also added a test case.

Thanks

ivelkov added 2 commits August 15, 2017 15:33
Tests are run against both Hibernate and EclipseLink JPA
+ Fixing tests when using hibernate
+ Fixing an issue where nested joins fail with an IllegalStateException: Illegal attempt to dereference path source
+ Adding a test case for the nested join
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 7b0d722 on ivelkov:master into 7458a9e on tennaito:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 7b0d722 on ivelkov:master into 7458a9e on tennaito:master.

@josiahhaswell
Copy link

What's the status on this? Is this project being maintained?

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

Successfully merging this pull request may close these issues.

3 participants