Reduce boilerplate code for long paths
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Querydsl |
Fix Released
|
Wishlist
|
Timo Westkämper |
Bug Description
Now if I have entity with links to other entities I cannot use long path easily.
E.g.
QEntity.
It produces null pointer exception, because path is not initialized. One way is to use @QueryInit, but it is not very neat solution - it pollutes entity class and requires "string" name.
Other solution is something like
QLink1 l1 = new QLink1(
QLink2 l2 = new QLink2(
It works but it's very verbose.
Is it possible to do something more friendly. I could suggest several variants:
1. generate yet another constructor new QLink1(
2. generate a special function QEntity.
I prefer the second variant.
> @QueryInit, but it is not very neat solution - it pollutes entity class and requires "string" name.
It is true, that QueryInit is not type-safe, but we didn't come up with a better solution.
> Is it possible to do something more friendly. I could suggest several variants: QEntity. entity. link1)
> 1. generate yet another constructor new QLink1(
Could you explain this more?
> 2. generate a special function QEntity. entity. link1.init( ).link2. init()
We had something like this before, but dropped it, because we favored the declarative approach with QueryInit. Providing manual initializations has the disadvantage, that the property paths cannot be declared final. We keep the paths final, so manual initialization is not an option.
Another alternative would be to provide QueryInit style initializations, but declare them elsewhere. For example in a package
@Initializations({ on(type= Entity. class, path="prop1.prop2") on(type= Entity2. class, path="prop3")
@Initializati
@Initializati
})
What do you think?