Student entity is defined as:
@Entity @XmlRootElement @NamedQuery(name="findAllStudents", query="select s from Student s") public class Student implements Serializable {
Persistence.xml is defined as:
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="HelloJavaEE7"> <properties> <property name="javax.persistence.schema-generation.database.action" value="drop-and-create" /> <property name="javax.persistence.schema-generation.create-source" value="metadata" /> <property name="javax.persistence.schema-generation.drop-source" value="metadata" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.format_sql" value="true" /> </properties> </persistence-unit> </persistence>
Editor shows a red cross on Student class declaration with the error message "Class "org.sample.Student" is managed, but is not listed in the persistence.xml file".
By default, all entities are included and this error should not occur.