Replies: 7 comments 2 replies
-
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 |
Beta Was this translation helpful? Give feedback.
-
@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. |
Beta Was this translation helpful? Give feedback.
-
same problem |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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:
|
Beta Was this translation helpful? Give feedback.
-
Why is it (#2166) closed? I was looking for same way/workaround just to solve what LukeChow said. |
Beta Was this translation helpful? Give feedback.
-
#2166 is closed because it was converted into this discussion (as it was merely a question). I would highly discourage mixing up DTO's and Entities. But feel free to pursue getting this to work 😉 |
Beta Was this translation helpful? Give feedback.
-
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.Beta Was this translation helpful? Give feedback.
All reactions