This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
How to get all columns of a bean to use in a projection ? #2166
Comments
So... I made an dirty alternative way to have dynamic column list...
Using an array is required for trans-typing in Now you all have seen the inside of my "dirty |
@timowest, To clarify the entire issue, this is what is happening: This format works fine:
However, if a try changing it to:
I get an error which is basically the result set returned the column name of one of the field (say width) of chair as col_1_1_ whereas based on the select clause, as printed in the logs, it should rather have been WIDTH_1_0_.
This is why I am forced to use the former syntax which even though works fine but is way too verbose. |
same problem |
Why project all columns at all if you can just project the entity itself which contains the columns? This makes no sense to me in a JPA environment. |
It makes sense when you select all columns of an entity(A) and join another entity(B) and select one column of B as a Transient variable in A.
Now, this is my codes:
But I want to do it with some codes like this:
|
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hello everybody,
Here is the context :
I have a stupid database constraint that forces me to use a projection to get data from tables using joins conditions that use only one column of composite PKs (so not working with JPA specifications of
@OneToMany
and@ManyToOne
).My DBA doesn't want to hear about sequence generated IDs... she is very "old school" about DB modelling... she is in love with composite PKs... :(
So... I want to get all the columns of my main bean, and the other data I need.
Yes, it's simple, and I managed to do it by iterating on every column of my bean, no problem.
Something like that :
Projections.bean(qMainBean, qMainBean.firstField, ..., qOtherBean, qStupidJoinBean)
But here is my problem :
Every time I want to add a new column in my
@Entity
bean, I need to go to modify my query to add that new column in my projection. First, that's annoying, and second, it's not good for maintaining the code.By searching on StackOverflow and then on QueryDSL documentation, I saw a
.all()
method on Q generated classes to get all the columns of my bean (that's a great thing !), but I don't have that method generated on my Q classes (that's a bad thing !).How can I get that method on my Q classes ? Am I missing something ?
My configuration :
Spring Platform Athens-SR5 as "parent" project, so QueryDSL 4.1.4 (and I use all libs in dependencies : core, jpa, collections, codegen, sql and apt)
And for generating Q classes, I use
com.querydsl.apt.hibernate.HibernateAnnotationProcessor
with jpa and apt libs as dependencies in my POM.The text was updated successfully, but these errors were encountered: