You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Abstract class "A" (MappedSuperclass) <|-- Abstract class "B" (@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)) <|-- Concrete Class "C"
Concrete class C has an One to One relationship with class D and Object D an One to One relationship with class E
I'm doing an Interface that extends Specification< B >
I do a join on D (looking from perspective of C, I think it's implicit).
When I add another join on D.E it fails with :
"Unable to locate Attribute with the the given name [attribute name of D on C class] on this ManagedType [class A]; nested exception is java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [attribute name of D on C class] on this ManagedType [class A]"
When I add another level (D.E) it fails to downcast and starts looking D on A.
Any idea on this?
Should I use Criteria API with treat to down cast?
Is something wrong in my logic?
Thank you in advance.
The text was updated successfully, but these errors were encountered:
The provided information are not sufficient to determine is described behaviour is a bug or not.
I've tried to reproduce your logic and it looks that everything works fine. Please take a look and let me know if there is any difference between my implementation and yours.
public class HierarchicalTest extends E2eTestBase {
@MappedSuperclass
public abstract class A {
@Id
@GeneratedValue
Long id;
String note;
public A(String note) {
this.note = note;
}
public A() {
}
public Long getId() {
return id;
}
public String getNote() {
return note;
}
}
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Entity
public abstract class B extends A {
public B(String note) {
super(note);
}
public B() {
super("default");
}
}
@Entity
public class C extends A {
@OneToOne
D d;
public C(String note, D d) {
super(note);
this.d = d;
}
public C() {
}
public D getD() {
return d;
}
}
@Entity
public class D {
@Id
@GeneratedValue
Long id;
@OneToOne
E e;
public D(E e) {
this.e = e;
}
public D() {
}
public E getE() {
return e;
}
}
@Entity
public class E {
@Id
@GeneratedValue
Long id;
String comment;
public E(String comment) {
this.comment = comment;
}
public E() {
}
public Long getId() {
return id;
}
public String getComment() {
return comment;
}
}
@Controller
public static class TestController {
@Autowired
CRepository cRepository;
@RequestMapping(value = "/test", params = { "comment" })
@ResponseBody
public Object findByNote(
@Join(path = "d", alias = "d")
@Join(path = "d.e", alias = "e")
@Spec(path = "e.comment", params = {"comment"}, spec = Equal.class) Specification<B> spec) {
return cRepository.findAll(spec);
}
}
@Test
public void findsByNote() throws Exception {
E e = new E("aaa");
D d = new D(e);
C c = new C("test", d);
em.persist(e);
em.persist(d);
em.persist(c);
mockMvc.perform(get("/test")
.param("comment", "aaa")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$").isArray())
.andExpect(jsonPath("$[?(@.d.e.comment=='aaa')]").exists())
.andReturn();
}
}
public interface CRepository extends PagingAndSortingRepository<HierarchicalTest.C, Long>, JpaSpecificationExecutor<HierarchicalTest.B> {
}
Hello,
I have an hierarchical chain of 3 objects:
Abstract class "A" (MappedSuperclass) <|-- Abstract class "B" (@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)) <|-- Concrete Class "C"
Concrete class C has an One to One relationship with class D and Object D an One to One relationship with class E
I'm doing an Interface that extends Specification< B >
I do a join on D (looking from perspective of C, I think it's implicit).
When I add another join on D.E it fails with :
"Unable to locate Attribute with the the given name [attribute name of D on C class] on this ManagedType [class A]; nested exception is java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [attribute name of D on C class] on this ManagedType [class A]"
When I add another level (D.E) it fails to downcast and starts looking D on A.
Any idea on this?
Should I use Criteria API with treat to down cast?
Is something wrong in my logic?
Thank you in advance.
The text was updated successfully, but these errors were encountered: