IceBlizz6 / querydsl-ksp

KSP for QueryDSL
3 stars 0 forks source link

User defined types (with UserType) having Collection as super class not working #6

Open xlaussel opened 2 weeks ago

xlaussel commented 2 weeks ago

I have an user defined type with Set as super:

class MySet : TreeSet<String>()

class MySetType : UserType<MySet>() {
...
}

I use it like that:

@Entity
class MyEntity {
    @Basic(fetch = FetchType.LAZY)
    @Column(nullable = false)
    @org.hibernate.annotations.Type(value = MySetType::class)
    var mySet = MySet();
}

Leads to the following error: [ksp] java.lang.IllegalStateException: Error processing MyEntity.mySet: Type looks like a set so expected 1 type arguments, but got 0 (It is just a simple reproduction of my case, I didn't test it but I am quite sure this will reproduce the bug)

I think there are two bugs:

  1. MySet should be treated as an user defined type and so there is no need to get the type argument. I think you should chek the @Type annotation prior to manage it as a Set. Anyway, there is no @OneToMany or @ManyToMany or @ElementCollection, so why do you manage it as a collection? The truth comes from the Annotations! So there is a structural problem.
  2. The type is a Set, so it has the wanted (but in this case not needed) type argument! Maybe you use a wrong method to get it.
IceBlizz6 commented 2 weeks ago

I think you should chek the @Type annotation prior to manage it as a Set.

Yes, i think this was the issue. I made it check @Type annotation first now instead of last.

ksp("com.github.IceBlizz6:querydsl-ksp:4698bab925") Please try this build to see if it solves this issue.