不是实体:类java.lang.Long在JPARepository中的remove方法中

时间:2015-07-22 18:36:23

标签: java hibernate postgresql liferay

我对Liferay服务器6.2 + Hibernate有奇怪的行为。 我已经创建了portlet,我已经部署在2个LF服务器上。此portlet正在与同一postgres db进行通信。除了删除方法外,一切正常。

错误消息仅在一个LF服务器上。

18:21:39,831 ERROR [DispatcherPortlet:559] Could not complete request
org.springframework.dao.InvalidDataAccessApiUsageException: Not an entity:class java.lang.Long; nested exception is java.lang.IllegalArgumentException: Not an entity:class java.lang.Long
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:296)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:106)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:403)
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at com.sun.proxy.$Proxy1288.delete(Unknown Source)

我有资源库

@Repository
public interface FavouritesRequestRepository extends JpaRepository<FavouritesRequest, Serializable>{

并使用此方法

@Override
    public void remove(Long id) {
         repository.delete(id);

    }

现在是POJO类

@Entity
@Table(name="Favouritesrequests")
@Access(value=AccessType.PROPERTY)
public class FavouritesRequest implements Serializable {

    private static final long serialVersionUID = 7432660452646512046L;

    private Long id=(long) 0;
    private Request request;

    private Long userId=(long) 0;;

@OneToOne()
@JoinColumn(name="REQID",  nullable=true)
public Request getRequest() {
    return request;
}

我曾尝试在存储库中构建自己的查询,但尚未成功。一台服务器上的错误消息保持不变。

Thanx寻求帮助。

0 个答案:

没有答案