Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.2.5
Mapping documents:
<class name="com.naipunya.sailom.domain.ScreenedStudent" table = "cscr_school_members" >
<id name ="id" column ="screening_id">
<generator class="native"/>
</id>
<component name="hospital" class="com.naipunya.sailom.domain.Hospital">
<property name="id" type="string" column="hospital_id"/>
</component>
<component name="patient" class="com.naipunya.sailom.domain.Patient">
<property name="firstName" type="string" column="first_name"/>
<property name="lastName" type="string" column="last_name"/>
<property name="sex" type="string" column="gender"/>
<property name="ageGroup" type="string" column="age_group"/>
<property name="caste" type="string" column="caste"/>
<property name="creed" type="string" column="creed"/>
<property name="religion" type="string" column="religion"/>
<property name="birthDate" type="date" column="dob"/>
<property name="bloodGroup" type="string" column="blood_group"/>
<property name="natureofComplaint" type="string" column="nature_complaint"/>
</component>
<property name="relation" type="string" column="relation"/>
<property name="relationFirstName" type="string" column="relation_first_name"/>
<property name="relationLastName" type="string" column="relation_last_name"/>
<property name="scheduledVisitDate" type="date" column="scheduled_visit_date"/>
<property name="actualVisitDate" type="date" column="actual_visit_date"/>
<property name="followupFlag" type="string" column="follow_up_flag"/>
<property name="createDate" type="date" column="creation_date"/>
<property name="createdBy" type="string" column="created_by"/>
<property name="updateDate" type="date" column="updated_date"/>
<property name="updatedBy" type="string" column="updated_by"/>
<many-to-one name="school" column="school_id" not-null="true" fetch = "join"/>
</class>
Code between sessionFactory.openSession() and session.close():
public class Person extends AbstractMedicalObject
{
private Address address;
private String age;
private String ageGroup;
private Date birthDate;
private String bloodGroup;
private String firstName;
private String lastName;
private String fatherFirstName;
private String fatherLastName;
private String sex;
private String caste;
private String creed;
private String religion;
--- I have getters and setters, for these i am not pasting it here because i want to keep this short
}
public class Patient extends Person
{
private String natureofComplaint;
private ReferringDoctor referredBy;
private String typeofPatient;
private Person nextKin;
private ScreenedPerson screenedPerson;
private ScreenedStudent screenedStudent;
}
public class ScreenedStudent extends AbstractMedicalObject {
private Hospital hospital;
private Patient patient;
private School school;
private Date scheduledVisitDate;
private Date actualVisitDate;
private String followupFlag;
private String relation;
private String relationFirstName;
private String relationLastName;
}
public List findSchoolMember(String stdLastName)
{
String nameLike;
List outputRec = new ArrayList();
try
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx = (Transaction)session.beginTransaction();
Criteria schCrit =
session.createCriteria(ScreenedStudent.class);
if (!"".equals(stdLastName))
{
nameLike = "%"+stdLastName+"%";
/* schCrit.add( Restrictions.like("lastName", nameLike )); */
schCrit.createCriteria("patient").add( Restrictions.like("lastName", nameLike ));
}
outputRec = schCrit.list();
tx.commit();
return outputRec;
}
catch (RuntimeException e) {
System.out.println("--getMakeList exception "+ e.getMessage());
e.printStackTrace();
throw e;
}
}
Full stack trace of any exception that occurs:
--getMakeList exception could not resolve property: lastName of: com.naipunya.sailom.domain.ScreenedStudent
org.hibernate.QueryException: could not resolve property: lastName of: com.naipunya.sailom.domain.ScreenedStudent
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:38)
at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1375)
at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:31)
at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1350)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:434)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:394)
at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:45)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:334)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:67)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1550)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.naipunya.sailom.finders.CommunityFinder101.findSchoolMember(CommunityFinder101.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283)
at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)
Name and version of the database you are using:
Mysql 5
The generated SQL (show_sql=true):
Not getting till here, the error occurs before the SQL is generated.
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html