-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: org.hibernate.MappingException: Unknown entity
PostPosted: Mon Jul 26, 2010 12:53 pm 
Newbie

Joined: Mon Jul 19, 2010 9:45 am
Posts: 2
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 ?


Top
 Profile  
 
 Post subject: Re: org.hibernate.MappingException: Unknown entity
PostPosted: Mon Jul 26, 2010 2:56 pm 
Newbie

Joined: Mon Jul 19, 2010 10:37 am
Posts: 5
could you please verify that ,Person entity has been loaded in your session factory,just check your configuration where you define mapping of all entity.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.