0

I have error in Spring JPA when I call findAll method:

org.springframework.data.mapping.PropertyReferenceException: No property package found for type models.Apk

@Entity
@Table(name="Apks")
public class Apk implements Serializable {

    @EmbeddedId private ApkPk id;
    @Column private String fileName;
    @Column private String description;
    @Column(updatable=false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date creationTime;
    @Column
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastUpdateTime;

    @ManyToOne
    @JoinColumn(name="appId", referencedColumnName="appId", insertable=false, updatable=false)
    @NotFound(action=NotFoundAction.IGNORE)
    @JsonIgnore
    private App app;


//Getters and setters
}


package mypackage.repositories;
public interface ApkRepository extends PagingAndSortingRepository<Apk, ApkPk> {

    public List<Apk> findByFileName(String value);

}

applicationContext.xml

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="persistenceUnitName" value="myjpa" />
</bean>

I have many repository classes but only this one occurs error. I found that Spring Data checks the naming convention according to the entity class, so my repository name should be ApkRepository. But it is not the case. What can I fix this problem? Any help would be appreciated.

EDIT: When I do unit test, it works fine. I happens error when it calls through service class.

repository.findAll(new PageRequest(1, 30));
4

0 回答 0