I'm trying to create a Spring project. In order to create query I used orm.xml
file:
<?xml version="1.0" encoding="UTF-8"?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd" version="2.0"> <named-query name="Student.getAllStudents"> <query>SELECT s FROM Student s</query> </named-query> </entity-mappings>
This is the interface StudentRepository.java in which this exception apprears:
The attribute nativeQuery is undefined for the annotation type Query
I'm asking the help to resolve this issue knowing that the version of Spring is 4.0.2. Thanks for your help.
Thanks to the help of @TG and this thread Setting up spring app with spring data repositories and mongo db , The caused problem is the version of spring data jpa
. --> So I move from spring-data-jpa-1.0.0.RELEASE.jar
to spring-data-jpa-1.5.0.RELEASE.jar
.As result, the exception disappears.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.