byenkya
(Joshua Byenkya)
October 6, 2022, 11:19am
1
Hello team,
How can I fix this error:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.MappingException: Unknown entity: org.openmrs.module.test.Department
This is how my hibernate file looks like
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="org.openmrs.module.test">
<class name="Department" table="test_department" lazy="false">
<id name="departmentId" type="int" column="department_id" unsaved-value="0">
<generator class="native" />
</id>
<discriminator column="department_id" insert="false" />
<property name="uuid" type="java.lang.String" column="uuid" length="38" unique="true" />
<property name="name" type="java.lang.String" column="name" length="255" unique="true" />
<property name="description" type="java.lang.String" column="description" length="255" />
</class>
</hibernate-mapping>
Any help is highly welcomed.
sharif
(Sharif Magembe)
October 6, 2022, 11:37am
2
@byenkya Sorry about this, Kindly share the entire log using pastebin.com . Also you could share git repository link for your department module.
sharif
(Sharif Magembe)
October 6, 2022, 12:11pm
4
Your Department.hbm.xml is not scanned in the classPath.
sharif
(Sharif Magembe)
October 6, 2022, 2:03pm
5
Hello @byenkya
Go ahead and add this file in Department.hbm.xml like this draft fix here
<hibernate-mapping package="org.openmrs.module.test">
<class name="Department" table="test_department" lazy="false">
<id name="departmentId" type="int" column="department_id" unsaved-value="0">
<generator class="native" />
<param name="sequence">test_department_department_id_seq</param>
</id>
<discriminator column="department_id" insert="false" />
<property name="uuid" type="java.lang.String" column="uuid" length="38" unique="true" />
<property name="name" type="java.lang.String" column="name" length="255" unique="true" />
<property name="description" type="java.lang.String" column="description" length="255" />
</class>
<mappingFiles>
Department.hbm.xml
</mappingFiles>
</hibernate-mapping>
Note that you need to also fix the department list. form. It’s not available so fix it in the controller by redirecting to a different form.
Added two lines one for Mapping files, and the param name. , i think we need to update our documentation for developing the basic module.
Best Regards