Seems IntelliJ 14 not support AbstractFacade class in EJB

I am quite new in IntelliJ. I tried to migrate one Java Project from Netbeans 8 to IntelliJ 14. But I found IntelliJ has no a way to support AbstractFacade.java in EJB (session bean) development.

Actually, as IntelliJ support EJB-3.2, Netbeans supports EJB-3.1. but seems there is no way to change very common AbstractFacade.java such as:

 
package com.longz.ozssc.intellij.ejb;

import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
import javax.persistence.EntityManager;
import java.util.List;

/**
* Created by cidylong on 6/12/2014.
*/

/*@Stateless(name = "AbstractFacadeEJB")*/
public abstract class
AbstractFacadeBean<T> {
    private Class<T> entityClass;

    public AbstractFacadeBean(Class<T> entityClass) {
        this.entityClass = entityClass;
    }

    protected AbstractFacadeBean() {
    }


    protected abstract EntityManager getEntityManager();

    public void create(T entity) {
        getEntityManager().persist(entity);
    }

    public void edit(T entity) {
        getEntityManager().merge(entity);
    }

    public void remove(T entity) {
        getEntityManager().remove(getEntityManager().merge(entity));
    }

    public T find(Object id) {
        return getEntityManager().find(entityClass, id);
    }

    public List<T> findAll() {
        javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
        cq.select(cq.from(entityClass));
        return getEntityManager().createQuery(cq).getResultList();
    }

    public List<T> findRange(int[] range) {
        javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
        cq.select(cq.from(entityClass));
        javax.persistence.Query q = getEntityManager().createQuery(cq);
        q.setMaxResults(range[1] - range[0] + 1);
        q.setFirstResult(range[0]);
        return q.getResultList();
    }

    public int count() {
        javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
        javax.persistence.criteria.Root<T> rt = cq.from(entityClass);
        cq.select(getEntityManager().getCriteriaBuilder().count(rt));
        javax.persistence.Query q = getEntityManager().createQuery(cq);
        return ((Long) q.getSingleResult()).intValue();
    }

}



The error message shows as: Class should not be defined as EJB and Interceptor at the same time.

details please see the attachment.

Appreciated



Attachment(s):
AbstracFacadeNotWork.png

Please sign in to leave a comment.