Pessoal, nao tenho ideia do que possa estar acontecendo, ja vi outros topicos aqui mais nada resolvel
Erro no console:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread “main” java.lang.IllegalArgumentException: Unknown entity: br.com.iw.prefeitura.modelo.Terreno
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:671)
at br.com.iw.prefeitura.testes.testeInsereTerreno.main(testeInsereTerreno.java:20)
Meu persistence.xml
<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 name="cimi">
<provider>org.hibernate.ejb.hibernatePersistence</provider>
<class>br.com.iw.prefeitura.modelo.Terreno</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/prefeitura"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root"/>
</properties>
</persistence-unit>
</persistence>
Minha classe
[code]
package br.com.iw.prefeitura.modelo;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.Entity;
@Entity
public class Terreno {
@Id @GeneratedValue
private int id;
private String benfeitoria;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getBenfeitoria() {
return benfeitoria;
}
public void setBenfeitoria(String benfeitoria) {
this.benfeitoria = benfeitoria;
}
}[/code]
meu Teste
package br.com.iw.prefeitura.testes;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import br.com.iw.prefeitura.modelo.Terreno;
public class testeInsereTerreno {
public static void main(String[] args) {
EntityManagerFactory factory = Persistence.createEntityManagerFactory("cimi");
EntityManager entityManager = factory.createEntityManager();
Terreno terreno = new Terreno();
terreno.setBenfeitoria("Muro e calçada");
entityManager.getTransaction().begin();
entityManager.persist(terreno);
entityManager.getTransaction().commit();
entityManager.close();
}
}
e nao vai… era para fucionar…