|
I'm having trouble with an entity named 'Patient'. I have another entity, "User" that isn't having this problem, yet they're both built in the same structure. (My project is following Ticketmonster's structure) I've stripped it of everything but the id but it still shows me the following error:
The given name of the entity "org.csmasters.project.mcc.model.Patient" is empty Patient.java /MCC2/src/main/java/org/csmasters/project/mcc/model line 12 JPA Problem
If I refactor-rename some names fix the problem (Random names: TesterClass, Xambalaya..etc.) and other don't; I've noticed that the entity names that don't work are ones that are used in one of my other projects, yet there's also another entity that they both have: "User" which doesn't have this problem. Cleaning the projects doesn't help; so if I remove the entity annotation and clean the project the problem goes away, and then with adding it and cleaning it returns.
Here's the entity: package org.csmasters.project.mcc.model;
import static javax.persistence.GenerationType.IDENTITY;
import java.io.Serializable;
import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id;
@SuppressWarnings("serial") @Entity public class Patient implements Serializable {
@Id @GeneratedValue(strategy = IDENTITY) private Long id;
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Patient other = (Patient) obj; if (id == null) { if (other.id != null) return false; }
else if (!id.equals(other.id)) return false; return true; }
@Override public String toString() { return "TestClass [id=" + id + "]"; }
}
Adding the name attribute of the entity annotation fixes the problem, but I'm not sure why the problem exists, or how setting the name attribute affects the code.
|