0

mysql db からこの処方リストを取得しています。私がやりたいことは、患者 ID でリストをフィルタリングし、フィルタリングされたリストを取得することです。

処方箋リストをうまく取得していますが、 filterList取得できません。以下は私のコードです。

@Override
    @Transactional
    public List<Prescription> retrieveAllPrescriptionsByPatientId(int id) {
        Session session=sessionFactory.getCurrentSession();
        List<Prescription>prescriptions = session.createCriteria(Prescription.class).list() ;   
        @SuppressWarnings("unchecked")
        List<Prescription> filterList =(List<Prescription>) session.createFilter(prescriptions, "where patient_Id = :id").setInteger("id", id).list();

        return (List<Prescription>)filterList;
    }

これは私が得ている例外です。

Exception in thread "main" org.hibernate.QueryException: The collection was unreferenced
    at org.hibernate.internal.SessionImpl.getFilterQueryPlan(SessionImpl.java:1483)
    at org.hibernate.internal.SessionImpl.createFilter(SessionImpl.java:1330)
    at com.tela.pms.dao.impl.PrescriptionDAOImpl.retrieveAllPrescriptionsByPatientId(PrescriptionDAOImpl.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at com.sun.proxy.$Proxy19.retrieveAllPrescriptionsByPatientId(Unknown Source)
    at com.tela.pms.service.impl.PrescriptionServiceImpl.retrieveAllPrescriptionsByPatientId(PrescriptionServiceImpl.java:47)
    at com.tela.pms.Test.HibernateTester.main(HibernateTester.java:45)

これで私を助けてください。ありがとう

4

0 に答える 0