-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: ClassCastException on a simple query
PostPosted: Wed Nov 29, 2006 8:05 pm 
Newbie

Joined: Wed Nov 29, 2006 6:55 pm
Posts: 10
I am working on my first Hibernate project. I have a fairly simple Query that I am trying to run, but no matter what I do, I get a ClassCastException. below are three attempts to query the database for a Client object:

Code:
Criteria criteria = session.createCriteria(Client.class);
criteria.add(Expression.eq("clientId", clientID));
return (Client)criteria.uniqueResult();


Code:
Query query = session.createQuery("from Client where clientId = " + clientID);
return (Client)query.uniqueResult();


I replaced it with this code and get the same exception
Code:
Client client = (Client) session.get(Client.class, clientID);
return client;


I have verified that the clientID used in the examples above is valid and the query does return an object. It only fails when I attempt to cast the object as a Client object.

When I step through the code and view the object in my "Expressions" window of Eclipse, it appears to be a Client object. It is only when I try to cast it to a Client, that I get this error.

I was reading something about proxies and am wondering if I am getting a proxy object instead of the object I am expecting...

I am not sure why this code would throw the ClassCastException.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 5:35 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Post POJOs, mapping files, code and exception stack trace

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 12:22 pm 
Newbie

Joined: Wed Nov 29, 2006 6:55 pm
Posts: 10
Exception (From JBoss log file):

Code:
2006-11-30 09:18:12,001 DEBUG [org.hibernate.engine.TwoPhaseLoad] done materializing entity [com.sosstaffing.trax.persistence.biolynx.Client#5133]
2006-11-30 09:18:12,001 DEBUG [org.hibernate.engine.StatefulPersistenceContext] initializing non-lazy collections
2006-11-30 09:18:12,001 DEBUG [org.hibernate.loader.Loader] done entity load
2006-11-30 09:18:12,001 ERROR [STDERR] java.lang.ClassCastException: com.sosstaffing.trax.persistence.biolynx.Client
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sosstaffing.trax.dao.ClientDAO.findByClientID(ClientDAO.java:52)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sosstaffing.trax.dao.ClientDAO.getRecursiveClients(ClientDAO.java:105)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sosstaffing.trax.dao.ClientDAO.getRecursiveClients(ClientDAO.java:128)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sosstaffing.trax.dao.ClientDAO.findByClientIDRecursive(ClientDAO.java:87)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sosstaffing.trax.web.components.handlers.EmployeeHandler.initPrivileges(EmployeeHandler.java:122)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sosstaffing.trax.web.components.handlers.EmployeeHandler.isMajorPrivilege(EmployeeHandler.java:97)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sosstaffing.trax.web.components.handlers.EmployeeHandler.isDEM(EmployeeHandler.java:88)
2006-11-30 09:18:12,001 ERROR [STDERR]    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2006-11-30 09:18:12,001 ERROR [STDERR]    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
2006-11-30 09:18:12,001 ERROR [STDERR]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
2006-11-30 09:18:12,001 ERROR [STDERR]    at java.lang.reflect.Method.invoke(Method.java:585)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:79)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:167)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:151)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:173)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
2006-11-30 09:18:12,001 ERROR [STDERR]    at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:315)
2006-11-30 09:18:12,001 ERROR [STDERR]    at javax.faces.webapp.UIComponentTag.shouldBeSuppressed(UIComponentTag.java:1281)
2006-11-30 09:18:12,001 ERROR [STDERR]    at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:475)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.taglib.html_basic.CommandButtonTag.doStartTag(CommandButtonTag.java:469)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.jsp.jsp.employee.maintenance.EmployeeEdit_jsp._jspx_meth_h_commandButton_2(EmployeeEdit_jsp.java:873)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.jsp.jsp.employee.maintenance.EmployeeEdit_jsp._jspx_meth_h_form_0(EmployeeEdit_jsp.java:300)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.jsp.jsp.employee.maintenance.EmployeeEdit_jsp._jspx_meth_f_view_0(EmployeeEdit_jsp.java:140)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.jsp.jsp.employee.maintenance.EmployeeEdit_jsp._jspService(EmployeeEdit_jsp.java:104)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
2006-11-30 09:18:12,001 ERROR [STDERR]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
2006-11-30 09:18:12,001 ERROR [STDERR]    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
2006-11-30 09:18:12,001 ERROR [STDERR]    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
2006-11-30 09:18:12,001 ERROR [STDERR]    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
2006-11-30 09:18:12,017 ERROR [STDERR]    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
2006-11-30 09:18:12,017 ERROR [STDERR]    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
2006-11-30 09:18:12,017 ERROR [STDERR]    at com.sosstaffing.trax.filter.UpdateSession.doFilter(UpdateSession.java:45)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
2006-11-30 09:18:12,017 ERROR [STDERR]    at com.sosstaffing.trax.filter.GUIDFilter.doFilter(GUIDFilter.java:86)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
2006-11-30 09:18:12,017 ERROR [STDERR]    at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
2006-11-30 09:18:12,017 ERROR [STDERR]    at java.lang.Thread.run(Thread.java:595)
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
2006-11-30 09:18:12,017 DEBUG [org.hibernate.SQL] select this_.client_id as client1_18_0_, this_.parent_id as parent2_18_0_, this_.description as descript3_18_0_, this_.client_number as client4_18_0_, this_.primary_contact as primary5_18_0_, this_.primary_phone as primary6_18_0_, this_.secondary_contact as secondary7_18_0_, this_.secondary_phone as secondary8_18_0_, this_.fax_number as fax9_18_0_, this_.accrual_flag as accrual10_18_0_, this_.billable_flag as billable11_18_0_, this_.pay_inv_flag as pay12_18_0_, this_.delete_flag as delete13_18_0_, this_.user_stamp as user14_18_0_, this_.long_desc as long15_18_0_, this_.job_flag as job16_18_0_, this_.payroll_key as payroll17_18_0_, this_.email_address as email18_18_0_ from BioLynx.dbo.client this_ where this_.parent_id=?
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open ResultSet (open ResultSets: 0, globally: 0)
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
2006-11-30 09:18:12,017 DEBUG [org.hibernate.jdbc.JDBCContext] TransactionFactory reported no active transaction; Synchronization not registered





Mapping File:


Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Nov 28, 2006 11:38:34 AM by Hibernate Tools 3.2.0.beta6a -->
<hibernate-mapping>
    <class name="com.sosstaffing.trax.persistence.biolynx.Employee" table="employee" schema="dbo" catalog="BioLynx">
        <id name="employeeId" type="java.lang.Integer">
            <column name="employee_id" />
            <generator class="identity">
            </generator>
        </id>
               
        <property name="securityId" type="int">
            <column name="security_id" />
        </property>
       
        <property name="clientId" type="int">
            <column name="client_id" />
        </property>
               
        <property name="employeeNumber" type="long">
            <column name="employee_number" precision="11" scale="0" not-null="true" />
        </property>

        <property name="firstName" type="string">
            <column name="first_name" length="50" not-null="true" />
        </property>

        <property name="lastName" type="string">
            <column name="last_name" length="50" not-null="true" />
        </property>

        <property name="middleName" type="string">
            <column name="middle_name" length="50" not-null="true" />
        </property>

        <property name="template" type="string">
            <column name="template" length="50" not-null="true" />
        </property>

        <property name="rejectThreshold" type="short">
            <column name="reject_threshold" not-null="true" />
        </property>

        <property name="deleteFlag" type="boolean">
            <column name="delete_flag" not-null="true" />
        </property>

        <property name="userStamp" type="int">
            <column name="user_stamp" not-null="true" />
        </property>

        <property name="depart" type="string">
            <column name="depart" length="50" not-null="true" />
        </property>

        <property name="clientEmpNumber" type="string">
            <column name="client_emp_number" length="50" not-null="true" />
        </property>

        <property name="exemptFlag" type="boolean">
            <column name="exempt_flag" not-null="true" />
        </property>

        <property name="reportFlag" type="boolean">
            <column name="report_flag" not-null="true" />
        </property>

        <property name="portalFlag" type="boolean">
            <column name="portal_flag" not-null="true" />
        </property>

        <property name="ipSingle" type="string">
            <column name="ip_single" length="50" />
        </property>

        <property name="ipFrom" type="string">
            <column name="ip_from" length="50" />
        </property>

        <property name="ipTo" type="string">
            <column name="ip_to" length="50" />
        </property>

        <property name="domain" type="string">
            <column name="domain" length="64" />
        </property>

        <property name="timeZone" type="java.lang.Short">
            <column name="time_zone" />
        </property>

        <property name="timeObserv" type="java.lang.Short">
            <column name="time_observ" />
        </property>

        <property name="defaultJob" type="java.lang.Integer">
            <column name="default_job" />
        </property>

        <property name="created" type="timestamp">
            <column name="created" length="23" />
        </property>

    </class>
</hibernate-mapping>




POJO:

Code:
/**
* Employee generated by hbm2java
*/
@Entity
@Table(name="employee"
    ,schema="dbo"
    ,catalog="BioLynx"
    , uniqueConstraints = {  }
)
public class Employee  implements java.io.Serializable {

    // Fields   
    private static final long serialVersionUID = -264588348745900447L;
    private int clientId;
    private int securityId;
     private Integer employeeId;
     private long employeeNumber;
     private String firstName;
     private String lastName;
     private String middleName;
     private String template;
     private short rejectThreshold;
     private boolean deleteFlag;
     private int userStamp;
     private String depart;
     private String clientEmpNumber;
     private boolean exemptFlag;
     private boolean reportFlag;
     private boolean portalFlag;
     private String ipSingle;
     private String ipFrom;
     private String ipTo;
     private String domain;
     private Short timeZone;
     private Short timeObserv;
     private Integer defaultJob;
     private Date created;

     // Constructors

    /** default constructor */
    public Employee() {
    }

   /** minimal constructor */
    public Employee(int clientId, long employeeNumber, String firstName, String lastName, String middleName, String template, short rejectThreshold, boolean deleteFlag, int userStamp, String depart, String clientEmpNumber, boolean exemptFlag, boolean reportFlag, boolean portalFlag) {
        this.clientId = clientId;
        this.employeeNumber = employeeNumber;
        this.firstName = firstName;
        this.lastName = lastName;
        this.middleName = middleName;
        this.template = template;
        this.rejectThreshold = rejectThreshold;
        this.deleteFlag = deleteFlag;
        this.userStamp = userStamp;
        this.depart = depart;
        this.clientEmpNumber = clientEmpNumber;
        this.exemptFlag = exemptFlag;
        this.reportFlag = reportFlag;
        this.portalFlag = portalFlag;
    }
    /** full constructor */
    public Employee(int clientId, int securityId, long employeeNumber, String firstName, String lastName, String middleName, String template, short rejectThreshold, boolean deleteFlag, int userStamp, String depart, String clientEmpNumber, boolean exemptFlag, boolean reportFlag, boolean portalFlag, String ipSingle, String ipFrom, String ipTo, String domain, Short timeZone, Short timeObserv, Integer defaultJob, Date created) {
       this.clientId = clientId;
       this.securityId = securityId;
       this.employeeNumber = employeeNumber;
       this.firstName = firstName;
       this.lastName = lastName;
       this.middleName = middleName;
       this.template = template;
       this.rejectThreshold = rejectThreshold;
       this.deleteFlag = deleteFlag;
       this.userStamp = userStamp;
       this.depart = depart;
       this.clientEmpNumber = clientEmpNumber;
       this.exemptFlag = exemptFlag;
       this.reportFlag = reportFlag;
       this.portalFlag = portalFlag;
       this.ipSingle = ipSingle;
       this.ipFrom = ipFrom;
       this.ipTo = ipTo;
       this.domain = domain;
       this.timeZone = timeZone;
       this.timeObserv = timeObserv;
       this.defaultJob = defaultJob;
       this.created = created;
    }
   
   
    // Property accessors
     @Id @GeneratedValue(strategy=IDENTITY)
   
    @Column(name="employee_id", unique=true, nullable=false, insertable=true, updatable=true)
    public Integer getEmployeeId() {
        return this.employeeId;
    }
   
    public void setEmployeeId(Integer employeeId) {
        this.employeeId = employeeId;
    }

    @Column(name="security_id", unique=false, nullable=false, insertable=true, updatable=true, precision=11, scale=0)
    public int getSecurityId() {
        return this.securityId;
    }
   
    public void setSecurityId(int securityId) {
        this.securityId = securityId;
    }
   
    @Column(name="client_id", unique=false, nullable=false, insertable=true, updatable=true, precision=11, scale=0)
    public int getClientId() {
        return this.clientId;
    }
   
    public void setClientId(int clientId) {
        this.clientId = clientId;
    }
   
    @Column(name="employee_number", unique=false, nullable=false, insertable=true, updatable=true, precision=11, scale=0)
    public long getEmployeeNumber() {
        return this.employeeNumber;
    }
   
    public void setEmployeeNumber(long employeeNumber) {
        this.employeeNumber = employeeNumber;
    }
   
    @Column(name="first_name", unique=false, nullable=false, insertable=true, updatable=true, length=50)
    public String getFirstName() {
        return this.firstName;
    }
   
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
   
    @Column(name="last_name", unique=false, nullable=false, insertable=true, updatable=true, length=50)
    public String getLastName() {
        return this.lastName;
    }
   
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
   
    @Column(name="middle_name", unique=false, nullable=false, insertable=true, updatable=true, length=50)
    public String getMiddleName() {
        return this.middleName;
    }
   
    public void setMiddleName(String middleName) {
        this.middleName = middleName;
    }
   
    @Column(name="template", unique=false, nullable=false, insertable=true, updatable=true, length=50)
    public String getTemplate() {
        return this.template;
    }
   
    public void setTemplate(String template) {
        this.template = template;
    }
   
    @Column(name="reject_threshold", unique=false, nullable=false, insertable=true, updatable=true)
    public short getRejectThreshold() {
        return this.rejectThreshold;
    }
   
    public void setRejectThreshold(short rejectThreshold) {
        this.rejectThreshold = rejectThreshold;
    }
   
    @Column(name="delete_flag", unique=false, nullable=false, insertable=true, updatable=true)
    public boolean isDeleteFlag() {
        return this.deleteFlag;
    }
   
    public void setDeleteFlag(boolean deleteFlag) {
        this.deleteFlag = deleteFlag;
    }
   
    @Column(name="user_stamp", unique=false, nullable=false, insertable=true, updatable=true)
    public int getUserStamp() {
        return this.userStamp;
    }
   
    public void setUserStamp(int userStamp) {
        this.userStamp = userStamp;
    }
   
    @Column(name="depart", unique=false, nullable=false, insertable=true, updatable=true, length=50)
    public String getDepart() {
        return this.depart;
    }
   
    public void setDepart(String depart) {
        this.depart = depart;
    }
   
    @Column(name="client_emp_number", unique=false, nullable=false, insertable=true, updatable=true, length=50)
    public String getClientEmpNumber() {
        return this.clientEmpNumber;
    }
   
    public void setClientEmpNumber(String clientEmpNumber) {
        this.clientEmpNumber = clientEmpNumber;
    }
   
    @Column(name="exempt_flag", unique=false, nullable=false, insertable=true, updatable=true)
    public boolean isExemptFlag() {
        return this.exemptFlag;
    }
   
    public void setExemptFlag(boolean exemptFlag) {
        this.exemptFlag = exemptFlag;
    }
   
    @Column(name="report_flag", unique=false, nullable=false, insertable=true, updatable=true)
    public boolean isReportFlag() {
        return this.reportFlag;
    }
   
    public void setReportFlag(boolean reportFlag) {
        this.reportFlag = reportFlag;
    }
   
    @Column(name="portal_flag", unique=false, nullable=false, insertable=true, updatable=true)
    public boolean isPortalFlag() {
        return this.portalFlag;
    }
   
    public void setPortalFlag(boolean portalFlag) {
        this.portalFlag = portalFlag;
    }
   
    @Column(name="ip_single", unique=false, nullable=true, insertable=true, updatable=true, length=50)
    public String getIpSingle() {
        return this.ipSingle;
    }
   
    public void setIpSingle(String ipSingle) {
        this.ipSingle = ipSingle;
    }
   
    @Column(name="ip_from", unique=false, nullable=true, insertable=true, updatable=true, length=50)
    public String getIpFrom() {
        return this.ipFrom;
    }
   
    public void setIpFrom(String ipFrom) {
        this.ipFrom = ipFrom;
    }
   
    @Column(name="ip_to", unique=false, nullable=true, insertable=true, updatable=true, length=50)
    public String getIpTo() {
        return this.ipTo;
    }
   
    public void setIpTo(String ipTo) {
        this.ipTo = ipTo;
    }
   
    @Column(name="domain", unique=false, nullable=true, insertable=true, updatable=true, length=64)
    public String getDomain() {
        return this.domain;
    }
   
    public void setDomain(String domain) {
        this.domain = domain;
    }
   
    @Column(name="time_zone", unique=false, nullable=true, insertable=true, updatable=true)
    public Short getTimeZone() {
        return this.timeZone;
    }
   
    public void setTimeZone(Short timeZone) {
        this.timeZone = timeZone;
    }
   
    @Column(name="time_observ", unique=false, nullable=true, insertable=true, updatable=true)
    public Short getTimeObserv() {
        return this.timeObserv;
    }
   
    public void setTimeObserv(Short timeObserv) {
        this.timeObserv = timeObserv;
    }
   
    @Column(name="default_job", unique=false, nullable=true, insertable=true, updatable=true)
    public Integer getDefaultJob() {
        return this.defaultJob;
    }
   
    public void setDefaultJob(Integer defaultJob) {
        this.defaultJob = defaultJob;
    }
   
    @Column(name="created", unique=false, nullable=true, insertable=true, updatable=true, length=23)
    public Date getCreated() {
        return this.created;
    }
   
    public void setCreated(Date created) {
        this.created = created;
    }


}
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 12:36 pm 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Your class is called Employee

the exception talks about Client...

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 1:28 pm 
Newbie

Joined: Wed Nov 29, 2006 6:55 pm
Posts: 10
Sorry about that. Both classes were having the same issue. Here is the Exception for the Client class
Code:
10:25:15,138 ERROR [STDERR] java.lang.ClassCastException: com.sosstaffing.trax.persistence.biolynx.Client
10:25:15,138 ERROR [STDERR]     at com.sosstaffing.trax.dao.ClientDAO.findByClientID(ClientDAO.java:52)
10:25:15,154 ERROR [STDERR]     at com.sosstaffing.trax.dao.ClientDAO.getRecursiveClients(ClientDAO.java:105)
10:25:15,154 ERROR [STDERR]     at com.sosstaffing.trax.dao.ClientDAO.getRecursiveClients(ClientDAO.java:128)
10:25:15,154 ERROR [STDERR]     at com.sosstaffing.trax.dao.ClientDAO.findByClientIDRecursive(ClientDAO.java:87)
10:25:15,154 ERROR [STDERR]     at com.sosstaffing.trax.web.components.handlers.EmployeeHandler.initPrivileges(EmployeeHandler.java:123)
10:25:15,154 ERROR [STDERR]     at com.sosstaffing.trax.web.components.handlers.EmployeeHandler.isMajorPrivilege(EmployeeHandler.java:98)
10:25:15,154 ERROR [STDERR]     at com.sosstaffing.trax.web.components.handlers.EmployeeHandler.isDEM(EmployeeHandler.java:88)
10:25:15,154 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:25:15,154 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
10:25:15,154 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
10:25:15,154 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Method.java:585)
10:25:15,154 ERROR [STDERR]     at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:79)
10:25:15,154 ERROR [STDERR]     at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:167)
10:25:15,154 ERROR [STDERR]     at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:151)
10:25:15,169 ERROR [STDERR]     at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243)
10:25:15,169 ERROR [STDERR]     at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:173)
10:25:15,169 ERROR [STDERR]     at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
10:25:15,169 ERROR [STDERR]     at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:315)
10:25:15,169 ERROR [STDERR]     at javax.faces.webapp.UIComponentTag.shouldBeSuppressed(UIComponentTag.java:1281)
10:25:15,169 ERROR [STDERR]     at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:475)
10:25:15,169 ERROR [STDERR]     at com.sun.faces.taglib.html_basic.CommandButtonTag.doStartTag(CommandButtonTag.java:469)
10:25:15,169 ERROR [STDERR]     at org.apache.jsp.jsp.employee.maintenance.EmployeeEdit_jsp._jspx_meth_h_commandButton_2(EmployeeEdit_jsp.java:873)
10:25:15,169 ERROR [STDERR]     at org.apache.jsp.jsp.employee.maintenance.EmployeeEdit_jsp._jspx_meth_h_form_0(EmployeeEdit_jsp.java:300)
10:25:15,169 ERROR [STDERR]     at org.apache.jsp.jsp.employee.maintenance.EmployeeEdit_jsp._jspx_meth_f_view_0(EmployeeEdit_jsp.java:140)
10:25:15,169 ERROR [STDERR]     at org.apache.jsp.jsp.employee.maintenance.EmployeeEdit_jsp._jspService(EmployeeEdit_jsp.java:104)
10:25:15,169 ERROR [STDERR]     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
10:25:15,169 ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
10:25:15,185 ERROR [STDERR]     at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
10:25:15,185 ERROR [STDERR]     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
10:25:15,185 ERROR [STDERR]     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
10:25:15,185 ERROR [STDERR]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
10:25:15,185 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
10:25:15,185 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
10:25:15,185 ERROR [STDERR]     at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
10:25:15,185 ERROR [STDERR]     at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
10:25:15,185 ERROR [STDERR]     at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
10:25:15,185 ERROR [STDERR]     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
10:25:15,185 ERROR [STDERR]     at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
10:25:15,185 ERROR [STDERR]     at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
10:25:15,185 ERROR [STDERR]     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
10:25:15,201 ERROR [STDERR]     at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
10:25:15,201 ERROR [STDERR]     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
10:25:15,201 ERROR [STDERR]     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
10:25:15,201 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
10:25:15,201 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
10:25:15,201 ERROR [STDERR]     at com.sosstaffing.trax.filter.UpdateSession.doFilter(UpdateSession.java:45)
10:25:15,201 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
10:25:15,201 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
10:25:15,201 ERROR [STDERR]     at com.sosstaffing.trax.filter.GUIDFilter.doFilter(GUIDFilter.java:86)
10:25:15,201 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
10:25:15,201 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
10:25:15,201 ERROR [STDERR]     at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
10:25:15,201 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
10:25:15,201 ERROR [STDERR]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
10:25:15,216 ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
10:25:15,216 ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
10:25:15,216 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
10:25:15,216 ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
10:25:15,216 ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
10:25:15,216 ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
10:25:15,216 ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
10:25:15,216 ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
10:25:15,216 ERROR [STDERR]     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
10:25:15,216 ERROR [STDERR]     at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
10:25:15,216 ERROR [STDERR]     at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
10:25:15,216 ERROR [STDERR]     at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
10:25:15,216 ERROR [STDERR]     at java.lang.Thread.run(Thread.java:595)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 1:44 pm 
Newbie

Joined: Wed Nov 29, 2006 6:55 pm
Posts: 10
Sorry about the wild goose chase, it turns out I was stepping through the code from the wrong method call. The method call that was throwing the error was returning a null object.

Error Fixed....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 30, 2006 2:51 pm 
Newbie

Joined: Wed Nov 29, 2006 6:55 pm
Posts: 10
I later saw this error with my Employee object and it turned out that the error was caused by my mapping file and POJO. I had a property defined as an int value. In the database there was a null value in that field. When Hibernate tried to assign null to a primitive, this exception was thrown. I changed my ints to Integers where appropriate, and no more error.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.