hibernate 5.0.12找不到mysql列

vkc1a9a2  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(460)

存储库:

public interface SquadronTableRepository extends JpaRepository<SquadronTable, Long> {

    @Transactional
    @Query(value = "SELECT flightdata_id, Incoming_number, Date_of_flight, Flight_number, Departure, Arrival, Tail_number, KVS, VP, Deadline_cor_act, Cor_act_accepted, Risk_index, Talon_closure FROM flightdata WHERE AE=?1 ORDER BY flightdata_id DESC", nativeQuery = true)
    Collection<SquadronTable> findAllDesc(Byte AE);
}

此@query在parament中找不到列ae。问题是我在mysql中的名字是“ae”,我不能在mysql中重命名,因为我应该保持向后兼容性。但要尽量找到“ae”这个小字母。例外情况是:
java.sql.sqlexception:找不到列“ae”。
在@entity class中,此字段是:

@Entity(name = "SquadronTable")
@Table(name = "flightdata")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class SquadronTable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "flightdataId")
    private long id;

    @Column(name = "AE")
    private Byte AE;

我怎么能告诉冬眠去看“ae”栏呢?或者另一个变体,我只需要从我的模型类db中获得,有2个条件:
其中ae=5或4或另一个字节键-部门编号
并应按id按desc排序
提前谢谢!

j13ufse2

j13ufse21#

我发现这个决定是:
spring.jpa.hibernate.naming.physical strategy=org.hibernate.boot.model.naming.physicalnamingstrategystandardimpl

相关问题