Caused by:
org.hibernate.MappingException: Could not determine type for: controler.Role, for columns: [org.hibernate.mapping.Column(ROLE)]
Can you please help me on this?
this is my mapping class
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="controler.Role" table="ROLE">
开发者_如何学Python <id name="roleId" column="ROLEID">
<generator class="increment"/>
</id>
<property name="title" column="TITLE"/>
</class>
</hibernate-mapping>
the Role is a pojo class and i have the relevant table named Role in the JavaDB. The role table has attributes roleid(char) and roletitle(varchar)
Caused by: org.hibernate.MappingException: Could not determine type for: controler.Role, for columns: [org.hibernate.mapping.Column(ROLE)]
My initial assumption was wrong. But now that you mentioned JavaDB, I suspect that ROLE
is actually a reserved keyword. Try to enclose the table name in backticks in the mapping document:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="controler.Role" table="`ROLE`">
<id name="roleId" column="ROLEID">
<generator class="increment"/>
</id>
<property name="title" column="TITLE"/>
</class>
</hibernate-mapping>
References
- Hibernate reference guide
- 5.4. SQL quoted identifiers
Is the fully-qualified name of the Java class actually controler.Role
? What does the source code of the Role
class look like? Is it in a package named controler
?
Perhaps the name is simply misspelt.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="controler.Role" table="
ROLE">
<id name="roleId" type="int" column="ROLEID">
<generator class="increment"/>
</id>
<property name="title" column="TITLE"/>
</class>
</hibernate-mapping>
精彩评论