Closed maxlam79 closed 4 years ago
@wargun02 could you put together a reproducer? It will be easier to debug.
Thanks!
@gsmet I'm new to this project. Could you suggest how I can put together a reproducer, as in do I start a GitHub project, upload it? or attached a zip file containing all the codes?
As you prefer really. A GitHub project allows to discuss more easily I think but it's really no obligation.
Just create an empty Quarkus project, add the class necessary to reproduce your issue and push it.
@gsmet Here it is: https://github.com/wargun02/quarkus_issue_3408
I have changed the title to: "Weird JSON output from Entity class with @ManyToOne field."
@wargun02 thanks for the reproducer!
Here is the SQL that Hibernate is generating based on your query:
select
geostateen0_.uuid as uuid1_1_0_,
geocountry1_.country_code as country_1_0_1_,
geostateen0_.country_code as country_4_1_0_,
geostateen0_.state_code as state_co2_1_0_,
geostateen0_.state_name as state_na3_1_0_,
geocountry1_.country_name as country_2_0_1_
from
t_geo_state geostateen0_
inner join
t_geo_country geocountry1_
on geostateen0_.country_code=geocountry1_.country_code
where
geocountry1_.country_code=?
order by
geostateen0_.state_code limit ?
which seems to me that you are not executing the query you intended
Changing the query in the repository class to:
String jpql = "select gs from GeoStateEntity gs "
+ "join gs.geoCountryEntity gc "
+ "where gc.countryCode = :geoCountryCode ";
return list( jpql, Sort.by( "gs.stateCode" ), new HashMap< String, Object >( ) {{
put( "geoCountryCode", geoCountryCode );
}} );
with the "select gs from GeoStateEntity gs..." seems to work (instead of just "from GeoStateEntity gs...").
Anyway, I'm just following some example jpql from the documentation on Panache, thought I could save a few "keyboard typings".
If this is not a bug and it is intended to work at such, please close this issue.
But having the repository method returning "List< GeoStateEntity >", seems odd to me that the JSON output doesn't quite conform to what is in "GeoStateEntity".
Yes, which is why I think (from the little I looked at it) that you are not really returning GeoStateEntity from the query (due the join).
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you! We are doing this automatically to ensure out-of-date issues does not stay around indefinitely. If you believe this issue is still relevant please put a comment on it on why and if it truly needs to stay request or add 'pinned' label.
Say if I have an Entity class GeoCountryEntity
and another entity class GeoStateEntity:
Do note the geoCountryEntity field below which is annotated @JsonbTransient
A simple PanacheRepository class:
A REST Resource class:
I get very weird results like:
Expected Result Should Be
Environment:
Quarkus Version: 0.19.1 Java Version: openjdk version "11.0.4" 2019-07-16 LTS OpenJDK Runtime Environment Zulu11.33+15-CA (build 11.0.4+11-LTS) OpenJDK 64-Bit Server VM Zulu11.33+15-CA (build 11.0.4+11-LTS, mixed mode)