【问题标题】:Double selects one field, how to solve?双选一个字段,怎么解决?
【发布时间】:2019-10-27 15:24:25
【问题描述】:

我的项目: https://bitbucket.org/Chvalov/countrytest/

我不明白为什么数据库中的字段country_codelanguage_code被选中了两次。

Hibernate: 
    select
        translate0_.country_code as country_3_1_0_,
        translate0_.language_code as language2_1_0_,
        translate0_.country_code as country_3_1_1_,
        translate0_.language_code as language2_1_1_,
        translate0_.translate as translat1_1_1_ 
    from
        country_translate translate0_ 
    where
        translate0_.country_code=?

我该如何解决这个问题?

【问题讨论】:

    标签: spring hibernate jpa spring-data-jpa spring-data


    【解决方案1】:

    因为它们在CountryTranslateKeyCountryTranslate 中。

    【讨论】:

    • 是的,因为我使用注解@IdClass,但是在CountryTranslateKey类中只有字段没有用JPA注解标记,也试过用@Embeddable@EmbeddedId 做,结果是一样的:(
    • 告诉我如何解决这个问题或只使用 JPQL?
    猜你喜欢
    • 2022-06-15
    • 2023-02-08
    • 2015-04-07
    • 1970-01-01
    • 1970-01-01
    • 2019-01-15
    • 2022-12-03
    • 1970-01-01
    • 2014-11-30
    相关资源
    最近更新 更多