org.springframework.data.mapping.PropertyReference

Exception:

    org.springframework.data.mapping.PropertyReference:no property batch found for type.

Caused by:

    When i deploy i get an exception, "org.springframework.data.mapping.PropertyReference:no property batch found for type".

    I compare the entity and table,i don't found property batch and the mapping is corrent.

The revevant codes:

1.Entity

package com.trekiz.admin.modules.sys.entity;

import com.google.common.collect.Lists;
import com.trekiz.admin.common.persistence.DataEntity;
import com.trekiz.admin.common.utils.Collections3;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
import java.util.List;

/**
 * 系统提醒
 */
@Entity
@Table(name = "sys_remind")
@DynamicInsert
@DynamicUpdate
public class Remind extends DataEntity{
    private Integer id;                         // 编号
    private String remindName;                  // 提醒名称
    private int remindType;                     // 提醒类型, 1 还款提醒
    private int selectedRemindType;             // 选择类型, 1 全部团期 2 指定团期
    private String selectedRemindOrderType;     // 选择提醒团期类性

    private int startRemindStatus;              // 提醒起始时间状态 -1 前 0 等于 1 后
    private int startRemindDays;                // 提醒起始天数
    private int startRemindHours;               // 提醒起始小时
    private int startRemindMinutes;             // 提醒起始分钟

    private int endRemindStatus;                // 提醒过期时间状态 -1 前 0 等于 1 后
    private int endRemindDays;                  // 提醒过期天数
    private int endRemindHours;                 // 提醒过期小时
    private int endRemindMinutes;               // 提醒过期分钟

    private Long companyId;                     // 所属批发商id
    private List<User> userList;                // 可见用户

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "remind_name")
    public String getRemindName() {
        return remindName;
    }

    public void setRemindName(String remindName) {
        this.remindName = remindName;
    }

    @Column(name = "remind_type")
    public int getRemindType() {
        return remindType;
    }

    public void setRemindType(int remindType) {
        this.remindType = remindType;
    }

    @Column(name = "selected_remind_type")
    public int getSelectedRemindType() {
        return selectedRemindType;
    }

    public void setSelectedRemindType(int selectedRemindType) {
        this.selectedRemindType = selectedRemindType;
    }

    @Column(name = "selected_remind_order_type")
    public String getSelectedRemindOrderType() {
        return selectedRemindOrderType;
    }

    public void setSelectedRemindOrderType(String selectedRemindOrderType) {
        this.selectedRemindOrderType = selectedRemindOrderType;
    }

    @Column(name = "start_remind_status")
    public int getStartRemindStatus() {
        return startRemindStatus;
    }

    public void setStartRemindStatus(int startRemindStatus) {
        this.startRemindStatus = startRemindStatus;
    }

    @Column(name = "start_remind_days")
    public int getStartRemindDays() {
        return startRemindDays;
    }

    public void setStartRemindDays(int startRemindDays) {
        this.startRemindDays = startRemindDays;
    }

    @Column(name = "start_remind_hours")
    public int getStartRemindHours() {
        return startRemindHours;
    }

    public void setStartRemindHours(int startRemindHours) {
        this.startRemindHours = startRemindHours;
    }

    @Column(name = "start_remind_minutes")
    public int getStartRemindMinutes() {
        return startRemindMinutes;
    }

    public void setStartRemindMinutes(int startRemindMinutes) {
        this.startRemindMinutes = startRemindMinutes;
    }

    @Column(name = "end_remind_status")
    public int getEndRemindStatus() {
        return endRemindStatus;
    }

    public void setEndRemindStatus(int endRemindStatus) {
        this.endRemindStatus = endRemindStatus;
    }

    @Column(name = "end_remind_days")
    public int getEndRemindDays() {
        return endRemindDays;
    }

    public void setEndRemindDays(int endRemindDays) {
        this.endRemindDays = endRemindDays;
    }

    @Column(name = "end_remind_hours")
    public int getEndRemindHours() {
        return endRemindHours;
    }

    public void setEndRemindHours(int endRemindHours) {
        this.endRemindHours = endRemindHours;
    }

    @Column(name = "end_remind_minutes")
    public int getEndRemindMinutes() {
        return endRemindMinutes;
    }

    public void setEndRemindMinutes(int endRemindMinutes) {
        this.endRemindMinutes = endRemindMinutes;
    }


    @Column(name = "company_id")
    public Long getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Long companyId) {
        this.companyId = companyId;
    }

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "sys_remind_user", joinColumns = { @JoinColumn(name = "remind_id") }, inverseJoinColumns = { @JoinColumn(name = "user_id") })
    @Where(clause = "delFlag='" + DEL_FLAG_NORMAL + "'")
    @Fetch(FetchMode.SUBSELECT)
    @NotFound(action = NotFoundAction.IGNORE)
    public List<User> getUserList() {
        return userList;
    }

    public void setUserList(List<User> userList) {
        this.userList = userList;
    }

    @Transient
    public String getUserIds() {
        return Collections3.convertToString(getUserIdList(), ",");
    }

    @Transient
    public List<Long> getUserIdList() {
        List<Long> userIdList = Lists.newArrayList();
        if (userList != null) {
            for (User user : userList) {
                userIdList.add(user.getId());
            }
        }
        return userIdList;
    }

    @Transient
    public void setUserIdList(List<Long> userIdList) {
        userList = Lists.newArrayList();
        if (userIdList != null) {
            for (Long userId : userIdList) {
                User user = new User();
                boolean flag = true;
                user.setId(userId);
                for(int i=0;i<userList.size();i++)
                {
                    if(userList.get(i).getId().toString().equals(userId.toString())  )
                    {
                        flag =false;
                        continue;
                    }
                }
                if(flag == true)
                    userList.add(user);
            }

        }
    }
}
2.Dao
package com.trekiz.admin.modules.sys.repository;

import com.trekiz.admin.common.persistence.BaseDao;
import com.trekiz.admin.common.persistence.BaseDaoImpl;
import com.trekiz.admin.modules.sys.entity.Remind;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

public interface RemindDao extends RemindDaoCustom, CrudRepository<Remind, Integer> {


}

interface RemindDaoCustom extends BaseDao<Remind> {

}

@Repository
class RemindDaoCustomImpl extends BaseDaoImpl<Remind> implements RemindDaoCustom{

}
3.Service
package com.trekiz.admin.modules.sys.service;

public interface IRemindService {
}
package com.trekiz.admin.modules.sys.service.impl;

import com.trekiz.admin.modules.sys.repository.RemindDao;
import com.trekiz.admin.modules.sys.service.IRemindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RemindServiceImpl implements IRemindService {
    @Autowired
    private RemindDao remindDao;

}
4.Controller
package com.trekiz.admin.modules.sys.web;

import com.trekiz.admin.modules.sys.service.IRemindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class RemindController {
    @Autowired
    private IRemindService remindService;
}
5.Exception(the root caused by)
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property batch found for type com.trekiz.admin.modules.sys.entity.Remind
	at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:271) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:245) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.repository.query.parser.Part.<init>(Part.java:72) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:180) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:260) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:240) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:68) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:57) ~[spring-data-jpa-1.3.0.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:90) ~[spring-data-jpa-1.3.0.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:162) ~[spring-data-jpa-1.3.0.RELEASE.jar:na]
	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68) ~[spring-data-jpa-1.3.0.RELEASE.jar:na]
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:279) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:147) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:153) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:43) ~[spring-data-commons-1.5.0.RELEASE.jar:na]
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142) ~[spring-beans-3.2.2.RELEASE.jar:3.2.2.RELEASE]
	... 88 common frames omitted

Solution:

http://stackoverflow.com/questions/20777785/org-springframework-data-mapping-propertyreferenceexception-no-property-catch-f/20789040#20789040

Answer:

If the name of your jpa repository interface is LocaleJpaRepository, your new custom interface should be named LocaleJpaRepositoryCustom, but the class that makes the override in the method must be named LocaleJpaRepositoryImpl, as it follows:

public class LocalJpaRepositoryImpl implements LocalJpaRepositoryCustom{
@Override
   public void customMethod(){....}
}
Summary:

the implementation class of your custom interface should start with the name of your repository interface (JPARepository) ending with 'Impl' keyword.

转载于:https://my.oschina.net/javaGeeker/blog/648738

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值