hasitha
hasitha

Reputation: 11

Hibernate+Spring framework project mapping error(exception)

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">
      <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)

Upvotes: 1

Views: 287

Answers (3)

chandru
chandru

Reputation: 1

<?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>

Upvotes: 0

matt b
matt b

Reputation: 139971

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.

Upvotes: 0

Pascal Thivent
Pascal Thivent

Reputation: 570505

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

Upvotes: 3

Related Questions