Hi i deployed my application to jboss and i get following exception when saving Person object
Code:
org.hibernate.MappingException: Unknown entity: sk.banik.app.myfirstapp.model.Person
org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:98)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
this is my Person.java
Code:
package sk.banik.app.myfirstapp.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.jboss.seam.annotations.Name;
@Entity
@Table(name = "person")
@Name("person")
public class Person implements Serializable {
@Id
@GeneratedValue
@Column(name = "ID")
private int id;
@Column(name = "firstName", length = 30)
private String firstName;
@Column(name = "lastName", length = 30)
private String lastName;
@Column(name="userName", length = 30)
private String userName;
@Column(name="password", length = 30)
private String password;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "person")
private List<Account> accounts = new ArrayList<Account>();
public Person() {
}
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return this.lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public List<Account> getAccounts() {
return this.accounts;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
hibernate.cfg.xml
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name= "java:/sessionFactory">
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="transaction.flush_before_completion">true</property>
<property name="connection.release_mode">after_statement</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="connection.datasource">java:/dataSource</property>
</session-factory>
</hibernate-configuration>
connection to db is defined in datasource.
The actual saving is from
Code:
@Stateful
@Name("personAction")
public class PersonAction implements PersonService, Serializable{
@In
private Session hibernateSession;
@DataModelSelection
@Out(required = false)
private Person active;
@DataModel(scope = ScopeType.PAGE)
private List<Person> personsList;
@Transactional(TransactionPropagationType.REQUIRED)
@Override
public void addPerson(Person person){
hibernateSession.save(person);
active = person;
FacesMessages.instance().add("New person with name: #{active.fisrtName},#{active.lastName} was saved");
getAllPersons();
}
can somebody help me ?