我的項目的SQL語句原來是采用HQL的,現在轉用Spring Boot +JPA+Hibernate, 出現以下問題,我估計是因爲HQL與JPQL的差異所致,請問如果我想繼續用HQL可以嗎? 如果可以,如何配置?
請問我如何知道我在用HQL還是用JPQL呢,如果我在用JPQL,又如何改成用HQL呢?
-
代碼:
@Entity
public class Place extends Groupunit_Defined implements Interface_Entity
{
......
@ManyToOne(targetEntity=Place_Definer.class)
@JoinColumn(name="Groupunit_Definer",nullable=false)
private Place_Definer Groupunit_Definer;//.....
}
@Entity
public class Place_Definer extends Groupunit_Definer
{
......
@Column(nullable=false,length=150)
private String Classification;
} SQL 語句
"SELECT * FROM Place p WHERE p.Groupunit_Definer.Classification='Jurisdiction'"
3.hibernate 設置
spring.jpa.database = MYSQL
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
4.報錯
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'Unit_Quantityp.Groupunit_Definer..Classification in 'where clause'