The Department class is displayed but not included in any persistence block.

I get this error, and I have no idea why: the Department class is displayed, but not included in any storage unit.

I have two projects. One of them In my persistence.xml, there are only two lines between the tag:

<persistence-unit name="UserJPA"> </persistence-unit> 

My class:

 package br.com.jm.user; import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.Column; import javax.persistence.Id; import javax.persistence.Table;; @Entity @Table(name = "DEPARTMENT") public class Department implements Serializable { private static final long serialVersionUID = 1L; @Id private Long id; private String name; //getters and setters } 

I am using EclipseLink2.1.2. In fact, I can remove this if it simplifies the situation.

Hugs, Demetrio

+8
java jpa eclipselink
source share
4 answers

For those who find this old question when searching for β€œThe xxxx class is displayed but not included in any unit error” in Eclipse or RAD, the comment of this question and answer has a solution that worked for me:

  • Right-click the project and select properties.
  • Choose JPA
  • Select the "Automatically open annotated classes" radio button
  • OK and wait for the project to complete.

These steps worked for me.

+13
source share

You need to specify which classes are included in the persistence block in the persistence.xml file, for example:

 <persistence-unit name="UserJPA"> <class>br.com.jm.user.Department</class> </persistence-unit> 
+10
source share

Right-click the persistance.xml file in the project explorer

then click Sync Class List

it automatically generates your class labels

enter image description here

+4
source share

persistence.xml should have:

 <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0"> <persistence-unit>..</persistence-unit> </persistence> 
+2
source share

All Articles