Hi,
I have entities that are departments, and departments can have parent departments. I am trying to use just one class to map this. However, when I try to do a query like:
Code:
"... where employee.department.id in (:departments)";
// departmentList is an arraylist of integers
q.setParameterList("departments", departmentList);
result = q.scroll();
I get a MappingException: no persister for java.lang.Integer
Can anyone give me a better way to map this?
The class looks like:
Code:
package com.cc.tss;
/*
*
* Java class "PaySection.java" generated from Poseidon for UML.
* Poseidon for UML is developed by <A HREF="http://www.gentleware.com">Gentleware</A>.
* Generated with <A HREF="http://jakarta.apache.org/velocity/">velocity</A> template engine.
*
*/
import java.io.Serializable;
public class Department implements Serializable {
///////////////////////////////////////
// attributes
/**
* Represents ...
*/
private String name;
private String shortName;
private String email;
private Integer id;
private Department parent;
/**
* Represents ...
*
*
* @return
*/
public Department() {
//parent = new Department();
}
public Department getParent() {
return parent;
}
public void setParent(Department d) {
parent = d;
}
public String getName() {
return name;
} // end getname
public void setName(String _name) {
name = _name;
} // end setname
public String getShortName() {
return shortName;
} // end getname
public void setShortName(String _name) {
shortName = _name;
} // end setname
public String getEmail() {
return email;
} // end getname
public void setEmail(String _name) {
email = _name;
} // end setname
public Integer getId() {
return id;
} // end getId
public void setId(Integer i) {
id = i;
}
public boolean needsPieceEntry(){
return DepartmentManager.needsPieceEntry(this);
}
}
and my mapping looks like:
Code:
<hibernate-mapping>
<!-- table created by: CREATE TABLE KEYWORDS ( ID IDENTITY, NAME VARCHAR(25) ); -->
<class name="com.cc.tss.Department" table="dept">
<id name="id" type="integer" column="id">
<generator class="sequence">
<param name="sequence">dept_id_seq</param>
</generator>
</id>
<property name="name" column="name" type="string" not-null="true"/>
<property name="shortName" column="short_name" type="string"/>
<property name="email" column="email" type="string"/>
<!--
<many-to-one
name="parent"
class="com.cc.tss.Department"
column="parent_id"/>
-->
</class>
</hibernate-mapping>
[/code]