I have a very simple object hierarchy in my app which uses JPA for inheritence:
Code:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public abstract class Party {
private Long id;
@Id @GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
Code:
@Entity
public class Person extends Party {
private String firstName;
private String lastName;
public Person() {
}
public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
@NotNull
@Length(min = 3, max = 40)
@Pattern(regex="[a-zA-Z]+", message="First name must only contain letters")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@NotNull
@Length(min = 3, max = 40)
@Pattern(regex="[a-zA-Z]+", message="Last name must only contain letters")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
I am able to save and retrieve the Person object in my tests. However, when JBoss tries to load the persitence unit, it gives me the following exception:
Code:
07:48:46.828 WARN [org.jboss.system.ServiceController] Problem starting service persistence.units:ear=myapp-1.0-SNAPSHOT.ear,unitName=myappDatabase
org.hibernate.AnnotationException: No identifier specified for entity: myapp.domain.party.Party
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:627)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
Clearly, I have specified an identifier for the Party object. Why is JBoss complaining?
Thanks.
Naresh