HQL을 위한 최대 절전 모드 구성
-
21-12-2019 - |
문제
가장 간단한 쿼리에 다음 오류가 발생합니다.
org.hibernate.hql.internal.ast.QuerySyntaxException: <table_name> is not mapped [<query_string>]
~ 안에 hibernate.cfg.xml
나는 재산을 가지고 있습니다.
<property name="current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</property>
ThreadLocalSessionContext
에 있습니다 org.hibernate.context.internal
~의 Hibernate 4.x-hibernate-core-4.2.6.Final.jar
.
Hibernate의 다른 모든 것은 잘 작동합니다.그러나 쿼리를 실행할 수 없습니다.
내가 무엇을 놓치고 있나요?
도와 주셔서 감사합니다.
//=========================
편집하다:
<table_name>
의 엔터티로 정의됩니다. hibernate.cfg.xml
그리고 모든 것 하지만 HQL은 다음 업데이트를 포함합니다. <table_name>
오류 없이 작업 중입니다.
해결책
내 마음에 오는 두 가지 가능성
-
HQL을 참조하는 이름은 엔티티가 아닙니다.e.g.,
HQL은 "Select Encentity Equentity에서 Select Equentity"를 사용하지만 Entity 클래스가 정의 된 Entity 클래스가 정의되지 않았습니다.
-
인증을 정의했지만 관리되지는 않습니다.엔티티의 다른 작업이 작동하고 있으며, HQL에서 잘못된 이름을 사용할 수있는 것처럼 보입니다. 그러나 엔티티가 관리되는지 확인하려면 Hibernate 디버그 로깅을 활성화 할 수 있으며 아래와 같은 정보를보아야합니다.
01:09:40,322 DEBUG HibernatePersistenceProvider:110 - Checking persistence-unit [name=persistence-unit_test, explicit-provider=org.hibernate.ejb.HibernatePersistence] against incoming persistence unit name [persistence-unit_demo] 01:09:40,322 DEBUG ProviderChecker:106 - Persistence-unit [persistence-unit_demo] requested PersistenceProvider [org.hibernate.ejb.HibernatePersistence] 01:09:40,322 DEBUG LogHelper:117 - PersistenceUnitInfo [ name: persistence-unit_demo persistence provider classname: org.hibernate.ejb.HibernatePersistence classloader: null excludeUnlistedClasses: false JTA datasource: null Non JTA datasource: null Transaction type: RESOURCE_LOCAL PU root URL: file:/E:/Test/target/classes/ Shared Cache Mode: null Validation Mode: null Jar files URLs [] Managed classes names [ com.test.model.TestEntity Mapping files names [] Properties [ hibernate.c3p0.timeout: 100 hibernate.connection.autocommit: false hibernate.connection.driver_class: com.mysql.jdbc.Driver hibernate.c3p0.max_statements: 0 hibernate.c3p0.max_size: 50 hibernate.dialect: org.hibernate.dialect.MySQL5InnoDBDialect hibernate.c3p0.idle_test_period: 100 hibernate.c3p0.min_size: 5 hibernate.connection.username: XXXX hibernate.hbm2ddl.auto: update hibernate.c3p0.acquire_increment: 5 hibernate.connection.url: jdbc:mysql://localhost:3306/test hibernate.connection.password: XXXX hibernate.show_sql: true hibernate.connection.provider_class: org.hibernate.connection.C3P0ConnectionProvider] 01:09:40,337 DEBUG IntegratorServiceImpl:63 - Adding Integrator [org.hibernate.cfg.beanvalidation.BeanValidationIntegrator]. 01:09:40,353 DEBUG IntegratorServiceImpl:63 - Adding Integrator [org.hibernate.secure.spi.JaccIntegrator].
또는
다른 팁
오류는 대부분 다음에서 발생합니다. query itself
.이름이 무엇인지 확인해야 합니다. Entity
요청을 실행 중인 이름은 다음의 이름과 정확히 같습니다. class
이름이 맘에 안 들어 SQL table
그것과 연관되어 있습니다.