Projection of SQL query onto JPA entities and aliases #540

Closed
msiedlarek opened this Issue Nov 4, 2013 · 3 comments

Comments

Projects
None yet
2 participants
@msiedlarek
Contributor

msiedlarek commented Nov 4, 2013

Projection of SQL query onto JPA entities relies on alias naming and there's not a word in the reference about it.

In the documentation there's this example code:

SAnimal cat = new SAnimal("cat");   
QCat catEntity = QCat.cat;    
List<Cat> cats = query.from(cat).orderBy(cat.name.asc()).list(catEntity);

It did not occur to me that this naming convention was necessary and I have gone through the entire process of coding, frustration and debugging to discover it.

If this behaviour is really best we can have (I believe it to be quite counterintuitive, as QueryDSL mostly handles aliases and paths not relaying on any names) maybe it should be documented accordingly, like:

QCat catEntity = QCat.cat;    
SAnimal cat = new SAnimal(catEntity.getMetadata().getName());   
@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 5, 2013

Member

I'd prefer to keep the original code example and add some documentation.

Mixing table and entity based Querydsl paths is what makes this example a bit tricky. And paths are unified by name at the serialization level.

I am not sure if this is counter-intuitive and I am not sure if there are good alternatives.

Member

timowest commented Nov 5, 2013

I'd prefer to keep the original code example and add some documentation.

Mixing table and entity based Querydsl paths is what makes this example a bit tricky. And paths are unified by name at the serialization level.

I am not sure if this is counter-intuitive and I am not sure if there are good alternatives.

timowest added a commit that referenced this issue Nov 6, 2013

@msiedlarek

This comment has been minimized.

Show comment
Hide comment
@msiedlarek

msiedlarek Nov 8, 2013

Contributor

Looks ok, thanks!

Contributor

msiedlarek commented Nov 8, 2013

Looks ok, thanks!

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Nov 17, 2013

Member

Released in 3.3.0.BETA1

Member

timowest commented Nov 17, 2013

Released in 3.3.0.BETA1

@timowest timowest closed this Nov 17, 2013

@timowest timowest added this to the 3.3.0 milestone Apr 13, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment