0

I am new to Open JPA and I am migrating my application DB services from JPA with Hibernate as vendor provider to JPA with OpenJPA as vendor Provider. Everything is fine, but I am not able to migrate my repositories. I am getting below error:

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property find found for
type com.entities.LevelPossibilityData
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:271)
    at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:245)
    at org.springframework.data.repository.query.parser.Part.<init>(Part.java:72)

Here is my entity:

package com.entities;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.lang.reflect.Field;

@Entity
@Table(name = "LEVEL_POSSIBILITY_DATA", schema = "DEV")
@NamedQueries({
    @NamedQuery(name = "LevelPossibilityData.findAllPossibilityGenIds", query = "SELECT distinct possibilityData.levelPossibilityGenId FROM LevelPossibilityData possibilityData where possibilityData.userCode is not null and possibilityData.possibilityType=?1  order by possibilityData.levelPossibilityGenId asc")})

public class LevelPossibilityData implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
@Column(name = "LEVEL_SEQ_ID")
private BigDecimal levelSeqId;

@Column(name = "LEVEL_USER_CODE")
private String userCode;

@Column(name = "LEVEL_USER_POSSIBILITY_TYPE")
private String possibilityType;

@Column(name = "LEVEL_POSSIBILITY_GENERATOR_ID")
private String levelPossibilityGenId;

}

and my Repository:

package com.dao;

import java.io.Serializable;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;

import com.entities.LevelPossibilityData;

public interface LevelPossibilityDataRepository<ID extends Serializable> extends JpaRepository<LevelPossibilityData, Serializable> {

public List<LevelPossibilityData> findAllPossibilityGenIds(String possibilityType); 

}

Can you please help me out in rectifying this error?

Atul Kumar
  • 75
  • 1
  • 13
  • Are you absolutely sure it was working ok with same version of spring-data-jpa but with hibernate? I mean haven't you change anything in mapping? I'm asking because this error seems to be high above JPA implementation issue... – makasprzak May 26 '14 at 18:52
  • Hi Macias, yes it was working fine with previous implementation (JPA with Hibernate as vendor provider). – Atul Kumar May 27 '14 at 05:42

1 Answers1

0

I was able to solve the issue by removing Named Queries from entity. I introduced queries directly into Repository by using @Query annotation.

Just one catch, if you are using openJPA and trying to use @Query in Repository, try to use full path of the entities used e.g. use "com.entities.LevelPossibilityData" instead of "LevelPossibilityData" in your query i.e. your query should be "select level from com.entities.LevelPossibilityData level" instead of "select level from LevelPossibilityData level".

I hope this explaination will be helpfull. Thanks everybody for devoting time on this.

Atul Kumar
  • 75
  • 1
  • 13