I'm currently getting an illegal argument exception on a getter for a Boolean, the
active property, when I try to do a query by example. I thought, at first, that it was because I was using the isXXXX() naming convention (which I thought might just work for primitive booleans) but using a getXXXX() naming convention fails as well. Anyone have any ideas?
Hibernate version:
2.1.6
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="x.x.x.model.sysadmin.UserVO"
table="ICIS_USER"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="USER_ID"
type="java.lang.String"
>
<generator class="assigned">
</generator>
</id>
<property
name="active"
type="x.x.x.common.server.dao.hibernate.ActiveInactiveType"
update="true"
insert="true"
access="property"
column="STATUS_FLAG"
/>
<property
name="dataAcessLevel"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="DATA_ACCESS_LEVEL_CODE"
/>
<property
name="dataAccessRegion"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="REGION_CODE"
/>
<property
name="sensitiveDataAccess"
type="x.x.x.common.server.dao.hibernate.ActiveInactiveType"
update="true"
insert="true"
access="property"
column="SENSITIVE_DATA_FLAG"
/>
<property
name="dataAccessState"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="STATE_CODE"
/>
<many-to-one
name="person"
class="x.x.x.model.sysadmin.PersonVO"
cascade="none"
outer-join="auto"
update="true"
insert="true"
access="property"
column="PERSON_ID"
/>
<set
name="roles"
table="XREF_USER_ROLE"
lazy="true"
inverse="false"
cascade="none"
sort="unsorted"
>
<key
column="USER_ID"
>
</key>
<many-to-many
class="x.x.x.model.sysadmin.RoleVO"
column="ROLE_ID"
outer-join="auto"
/>
</set>
</class>
<query name="sysadmin.getUserByID"><![CDATA[
from UserVO user where user.id = :id
]]></query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
package x.x.x.model.sysadmin;
import x.x.x.common.model.IModel;
import java.util.Set;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* A VO representing a user of the ICIS system.
*
* @author Chad La Joie
*
* @hibernate.class table="ICIS_USER"
*
* @hibernate.query name="sysadmin.getUserByID"
* query="from UserVO user where user.id = :id"
*/
public class UserVO implements IModel
{
public static final String HQ_ACCESS_LEVEL = "HQ";
public static final String HQ_READ_ONLY_ACCESS_LEVEL = "HQR";
public static final String REGION_ACCESS_LEVEL = "REG";
public static final String STATE_ACCESS_LEVEL = "ST";
private String id;
private Boolean active;
private String dataAcessLevel;
private Boolean sensitiveDataAccess;
private String dataAccessRegion;
private String dataAccessState;
private PersonVO person;
private Set roles;
/**
* Default constructor
*
*/
public UserVO(){
}
/**
* Gets whether this user account is active or not.
*
* @return whether this user account is active or not.
*
* @hibernate.property column="STATUS_FLAG" type="x.x.x.common.server.dao.hibernate.ActiveInactiveType"
*/
public Boolean isActive()
{
return active;
}
/**
* Sets whether this user account is active or not.
*
* @param accountState whether this user account is active or not.
*/
public void setActive(Boolean active)
{
this.active = active;
}
/**
* Gets the data access level of this user.
*
* @return the data access level of this user
*
* @hibernate.property column="DATA_ACCESS_LEVEL_CODE"
*/
public String getDataAcessLevel()
{
return dataAcessLevel;
}
/**
* Sets the data access level of this user.
*
* @param dataAcessLevel the data access level of this user
*/
public void setDataAcessLevel(String dataAcessLevel)
{
this.dataAcessLevel = dataAcessLevel;
}
/**
* Gets the code of the region this user operates out of.
*
* @return the code of the region this user operates out of
*
* @hibernate.property column="REGION_CODE"
*/
public String getDataAccessRegion()
{
return dataAccessRegion;
}
/**
* Sets the code of the region this user operates out of.
*
* @param regionCode the code of the region this user operates out of
*/
public void setDataAccessRegion(String regionCode)
{
this.dataAccessRegion = regionCode;
}
/**
* Gets the sensitive data acess string for the user
*
* @return the sensitive data acess string for the user
*
* @hibernate.property column="SENSITIVE_DATA_FLAG" type="x.x.x.common.server.dao.hibernate.ActiveInactiveType"
*/
public Boolean isSensitiveDataAccess()
{
return sensitiveDataAccess;
}
/**
* Sets the sensitive data acess string for the user
*
* @param sensitiveDataAccess the sensitive data acess string for the user
*/
public void setSensitiveDataAccess(boolean sensitiveDataAccess)
{
this.sensitiveDataAccess = new Boolean(sensitiveDataAccess);
}
/**
* Gets the abbreviated state this user works out of.
*
* @return the abbreviated state this user works out of
*
* @hibernate.property column="STATE_CODE"
*/
public String getDataAccessState()
{
return dataAccessState;
}
/**
* Sets the code of the state this user works out of
*
* @param state the code of the state this user works out of
*/
public void setDataAccessState(String stateCode)
{
this.dataAccessState = stateCode;
}
/**
* Gets the unique identifier for this user.
*
* @return the unique identifier for this user
*
* @hibernate.id generator-class="assigned" column="USER_ID"
*/
public String getId()
{
return id;
}
/**
* Sets the unique identifier for this user.
*
* @param id the unique identifier for this user
*/
public void setId(String id)
{
this.id = id;
}
/**
* Gets the person associated with this user.
*
* @return the person associated with this user
*
* @hibernate.many-to-one column="PERSON_ID"
*/
public PersonVO getPerson(){
return person;
}
/**
* Sets the person associated with this user.
*
* @param person the person associated with this user
*/
public void setPerson(PersonVO person){
this.person = person;
}
/**
* Gets the roles a user belongs to.
*
* @return a <code>Set</code> of <code>RoleVO</code>s representing the roles a user belongs to
*
* @hibernate.set table="XREF_USER_ROLE" lazy="true"
* @hibernate.collection-key column="USER_ID"
* @hibernate.collection-many-to-many column="ROLE_ID"
* class="x.x.x.model.sysadmin.RoleVO"
*/
public Set getRoles(){
return roles;
}
/**
* Sets the roles a user belongs to.
*
* @param roles the roles a user belongs to
*/
public void setRoles(Set roles){
this.roles = roles;
}
/**
* Returns a string resprentation of this user.
*
* @return a string resprentation of this user
*/
public String toString()
{
return new ToStringBuilder(this)
.append("User ID", getId())
.append(super.toString())
.append("Active", isActive())
.append("Data Access Level", getDataAcessLevel())
.append("Data Access Region", getDataAccessRegion())
.append("Data Access State", getDataAccessState())
.append("Sensitive Data Access", isSensitiveDataAccess())
.toString();
}
/**
* Tests another user VO for persistant identity equality. Two users
* have persistent identity equality if they have the same user ID.
*
* @return true if the user have persistant identity equality
*/
public boolean equals(Object other)
{
if (!(other instanceof UserVO))
return false;
UserVO otherUser = (UserVO) other;
return this.getId() == otherUser.getId();
}
/**
* Gets a hash representation for this user.
*
* @return a hash representation for this user
*/
public int hashCode()
{
return new HashCodeBuilder().append(getId()).toHashCode();
}
}
Full stack trace of any exception that occurs:
net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter: IllegalArgumentException occurred calling getter of xx.x.model.sysadmin
.UserVO.active
at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:110)
at net.sf.hibernate.persister.AbstractEntityPersister.getPropertyValues(AbstractEntityPersister.java:246)
at net.sf.hibernate.expression.Example.toSqlString(Example.java:165)
at net.sf.hibernate.loader.CriteriaLoader.<init>(CriteriaLoader.java:64)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3595)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
at x.x.x.dao.sysadmin.UserDAO.getUsers(UserDAO.java:135)
at x.x.x.sysadmin.server.cmd.SearchUserCmd.doWork(SearchUserCmd.java:56)
at x.x.x.common.server.cmd.BaseCmd.execute(BaseCmd.java:59)
at x.x.x.sysadmin.server.ejb.SystemAdminSB.searchUser(SystemAdminSB.java:83)
at x.x.x.sysadmin.server.ejb.SystemAdmin_qbf5pt_EOImpl.searchUser(SystemAdmin_qbf5pt_EOImpl.java:46)
at x.x.x.sysadmin.server.ejb.SystemAdmin_qbf5pt_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.ServerRequest.sendReceive(ServerRequest.java:166)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
at x.x.x.sysadmin.server.ejb.SystemAdmin_qbf5pt_EOImpl_813_WLStub.searchUser(Unknown Source)
at x.x.x.sysadmin.ui.SysadminDelegate.searchUser(SysadminDelegate.java:95)
at x.x.x.sysadmin.ui.action.SearchUserAction.doSearch(SearchUserAction.java:125)
at x.x.x.sysadmin.ui.action.SearchUserAction.execute(SearchUserAction.java:75)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6452)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
Name and version of the database you are using:
Oracle 9i, 9.0.2
The generated SQL (show_sql=true):
None generated (which is the problem)