Hi,
I am trying to create a custom JPA repository and have read everything I can find about the subject. The problem is that when I try to run my test, I get:
The method name is "myCustomNewPhysicianCustomMethod" and Spring data is trying to indicate that "my" is a property on the object UserMaster. Here are my interfaces and implementation file.Code:Caused by: org.springframework.data.mapping.PropertyReferenceException: No property my found for type com.presidioHealth.ppsDataLibrary.domain.presidio.UserMaster at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:74) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:326) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:352) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:352) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:352) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:352) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:352) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:306) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270) at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:244) at org.springframework.data.repository.query.parser.Part.<init>(Part.java:73) at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:180) at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:260) at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:240) at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:68) at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:57) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:90) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:162) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:280) at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:148) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:125) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:41) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142) ... 36 more
UserMasterRepositoryCustom.java
UserMasterRepositoryImplCode:public interface UserMasterRepositoryCustom { public abstract void myCustomNewPhysicianCustomMethod( String lastName, String firstName, String degree, String adtDoctorId, Long organizationId, String locationCode, String emailAddress, String password, Boolean emrOnly, Boolean autoFinalize, Boolean emailMode, String emailOverride); }
UserMasterRepositoryCode:package com.presidioHealth.ppsDataLibrary.repository.custom; import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; import javax.persistence.PersistenceContext; import javax.persistence.Query; import org.eclipse.persistence.annotations.Direction; import org.eclipse.persistence.annotations.NamedStoredProcedureQueries; import org.eclipse.persistence.annotations.NamedStoredProcedureQuery; import org.eclipse.persistence.annotations.StoredProcedureParameter; import org.springframework.data.jpa.repository.Modifying; @NamedStoredProcedureQueries({ @NamedStoredProcedureQuery( name="ADDNEWPHYSICIAN", procedureName="addNewPhysician", returnsResultSet=false, parameters={ @StoredProcedureParameter(queryParameter="lastName",name="p_lastName", type=String.class), @StoredProcedureParameter(queryParameter="firstName",name="p_firstName", type=String.class), @StoredProcedureParameter(queryParameter="degree",name="p_degree", type=String.class), @StoredProcedureParameter(queryParameter="adtDoctorId",name="p_degree", type=String.class), @StoredProcedureParameter(queryParameter="organizationId",name="p_organizationId", type=Long.class), @StoredProcedureParameter(queryParameter="locationCode",name="p_locationCode", type=String.class), @StoredProcedureParameter(queryParameter="emailAddress",name="p_emailAddress", type=String.class), @StoredProcedureParameter(queryParameter="password",name="p_password", type=String.class), @StoredProcedureParameter(queryParameter="emrOnly",name="p_emrOnly", type=Boolean.class), @StoredProcedureParameter(queryParameter="autoFinalize",name="p_autoFinalize", type=Boolean.class), @StoredProcedureParameter(queryParameter="emailMode",name="p_emailMode", type=Boolean.class), @StoredProcedureParameter(queryParameter="emailOverride",name="p_emailOverride", type=String.class) } ) }) public class UserMasterRepositoryImpl implements UserMasterRepositoryCustom { @PersistenceContext private EntityManager em; @Override public void myCustomNewPhysicianCustomMethod(String lastName, String firstName, String degree, String adtDoctorId, Long organizationId, String locationCode, String emailAddress, String password, Boolean emrOnly, Boolean autoFinalize, Boolean emailMode, String emailOverride) { do { EntityTransaction etx = em.getTransaction(); etx.begin(); Query q = em.createNamedQuery("ADDNEWPHYSICIAN"); q.setParameter("lastName", lastName); q.setParameter("firstName", firstName); q.setParameter("degree", degree); q.setParameter("adtDoctorId", adtDoctorId); q.setParameter("organizationId", organizationId); q.setParameter("locationCode", locationCode); q.setParameter("emailAddress", emailAddress); q.setParameter("password", password); q.setParameter("emrOnly", emrOnly); q.setParameter("autoFinalize", autoFinalize); q.setParameter("emailMode", emailMode); q.setParameter("emailOverride", emailOverride); try { Object xx = q.getSingleResult(); etx.commit(); } catch (Exception e) { e.printStackTrace(); } finally { em.close(); } } while (false); return; } }
Configuration file:Code:public interface UserMasterRepository extends JpaRepository<UserMaster, Long>, UserMasterRepositoryCustom { public UserMaster findByLogin(String login); }
My UserMaster object is a typical object that has user properties.Code:<jpa:repositories base-package="com.presidioHealth.ppsDataLibrary.repository.presidio" repository-impl-postfix="CustomImpl" />
So, the issue is that no matter what I name my method in my custom repository interface, it always takes the first characters before the first capital letter and tries to match that to a property in the UserMaster object.
What am I missing?
Thanks,
Tom


Reply With Quote
