Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

262
Views
Hibernate ÚNETE [alguna entidad] EN token inesperado

Uso Hibernate 5.4.32.Final , cuando intento ejecutar esta consulta a través de datos de primavera:

 @Query("select new some.package.dto.TwoFieldDto(o.gln, u.email) " + "from OrganizationEntity o " + "join UserEntity u on u.organization.id = o.id " + "where o.gln in (:glnList)") List<TwoFieldDto<String, String>> findEmailListByGlnIn(List<String> glnList);

Al iniciar la aplicación, Hibernate lanza SyntexException cuando llega al token de UserEntity y da un token inesperado.

Si trato de ejecutar la consulta desde el lado de UserEntity, la consulta se compila correctamente. (Sí, no tengo un enlace de OrganizationEntity a UserEntity)

¿Esta versión de Hibernate no es compatible con JOIN ON syntex? (OrganizationEntity no contiene un enlace en UserEntity, pero UserEntity lo tiene).

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

La anotación @Query espera JPQL por defecto, que tiene su propia sintaxis. Hasta donde yo sé, no puedes hacer algo como JOIN .. ON en JPQL. No conozco la asociación entre sus entidades, pero debería verse así:

 @Query("select new by.urspectr.ediprov.util.dto.TwoFieldDto(o.gln, u.email) " + "from OrganizationEntity o " + "join o.UserEntity u " + "where o.gln in (:glnList)")

Pero para que eso funcione, tiene que haber una asociación entre OrganizationEntity y UserEntity .

Como alternativa, siempre puede usar una consulta nativa, donde podría hacer JOIN .. ON en su dialecto SQL nativo:

 @Query(value = "SELECT ....", nativeQuery = true)

Pero esto solo debería ser una opción si está seguro de que no puede hacerlo con JPQL.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!