Я пытаюсь напечатать количество строк запроса, включенного в репозиторий. Вот репозиторий:
@Repository
public interface TagRepository extends EntityRepository<Tag, Long> {
/**
* @param //
* @return all Tag matched
*/
@Query("SELECT * FROM Tag") //TESTED
List<Tag> findByDefault();
}
Вот мой контроллер:
@Named
@ViewScoped
public class ControllerTest implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Inject
private TagRepository tagRepository;
public ControllerTest()
{
super();
}
public Integer compte()
{
return tagRepository.findByDefault().size();
}
public String essai()
{
String message = "Hello World !";
return message;
}
}
Вот мой файл *.xhtml:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ds="http://deltaspike.apache.org/jsf"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich" template="/layout/template.xhtml"
xmlns:a4j="http://richfaces.org/a4j">
<ui:define name="body">
<rich:collapsiblePanel switchType="client" opened="false" label="Updates version 2.2.7">
<h:outputText
value="#{controllerTest.compte()}">
</h:outputText>
<h:outputText
value="#{controllerTest.essai()}">
</h:outputText>
<h:outputText
value="Hello world !">
</h:outputText>
</rich:collapsiblePanel>
</ui:define>
The layout runs perfectly with the method essai()
but when I use the method compte()
:
javax.servlet.ServletException: Exception calling Repository: [Repository=class repositories.TagRepository$$DSPartialBeanProxy,method=findByDefault],exception=class java.lang.IllegalStateException,message=Could not find EntityManager with default qualifier.
Я думал, что Apache Deltaspike может управлять bean-компонентами самостоятельно с помощью аннотаций.
Вопрос: Откуда берется эта проблема? Это мой репозиторий? Я что-то пропустил ? Я все еще гуглил это, но ничего для Apache Deltaspike.
Я использую Wildfly 10.0.0, Hibernate 5.4.1, Eclipse Neon, RichFaces 4.X, JSF 2.X, Apache Deltaspike 1.7.2.
Заранее спасибо за ваши ответы.