Rodando jpa no netbeans

2 respostas
robson_vs

Estou tentando fazer um exemplo com jpa no netbeans mais estou tendo um pouco de dificildade veja a exception:

log4j:WARN No appenders could be found for logger (org.hibernate.ejb.Version).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:698)
        at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
        at br.com.nosbor.agenda.teste.PessoaTest.main(PessoaTest.java:27)
Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
        at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
        at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
        at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:409)
        at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:119)
        at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
        at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:691)
        ... 4 more
Java Result: 1

o persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" 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_1_0.xsd">
  <persistence-unit name="testePU" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>br.com.nosbor.agenda.modelo.Pessoa</class>
    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
      <property name="hibernate.connection.username" value="root"/>
      <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
      <property name="hibernate.connection.password" value="root"/>
      <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/agenda"/>
      <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
      <property name="show_sql" value="true"/>
    </properties>
  </persistence-unit>
</persistence>

2 Respostas

T

cara o Hibernate não está encontrando seu diateto… DETALHE!!! Perce ba quese vc está usando hibernate há 3 dialetos diferentes para o MYSQL. Há o ISAM, o padrão e o InnoDB… As strings são essas…

MySQL org.hibernate.dialect.MySQLDialect

MySQL with InnoDB-org.hibernate.dialect.MySQLInnoDBDialect

MySQL with MyISAM org.hibernate.dialect.MySQLMyISAMDialect

blz?

robson_vs

como faço para saber qual devo usar???

Tentei as tres mais todas deram o mesmo erro

Criado 11 de maio de 2007
Ultima resposta 11 de mai. de 2007
Respostas 2
Participantes 2