to com um exemplo q tah me dando muita dor de cabeça… ja vi q esse problema muita gente ja teve so que em situacoes diferente…
o erro é: Hibernate Dialect must be explicitly set e Hibernate Dialect must be explicitly set!
e que mesmo eu tirando o hibernate.cfg.xml ou persistence.xml o erro eh o mesmo…
os diretorios estao da seguinte forma:
hello
Helloworld.java
Message.java
META-INF
persistence.xml
as classes sao essas:
package hello;
import javax.persistence.*;
@Entity
@Table(name = “MESSAGES”)
public class Message {
@Id @GeneratedValue
@Column(name = “MESSAGE_ID”)
private Long id;
@Column(name = “MESSAGE_TEXT”)
private String text;
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = “NEXT_MESSAGE_ID”)
private Message nextMessage;
private Message() {}
public Message(String text) {
this.text = text;
}
public Long getId() {
return id;
}
private void setId(Long id) {
<a href="http://this.id">this.id</a> = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Message getNextMessage() {
return nextMessage;
}
public void setNextMessage(Message nextMessage) {
this.nextMessage = nextMessage;
}
}
package hello;
import java.util.;
import javax.persistence.;
public class HelloWorld {
public static void main(String[] args) {
// Start EntityManagerFactory
EntityManagerFactory emf = Persistence.createEntityManagerFactory("helloworld");
// First unit of work
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
Message message = new Message("Hello World");
em.persist(message);
tx.commit();
em.close();
// Second unit of work
EntityManager newEm = emf.createEntityManager();
EntityTransaction newTx = newEm.getTransaction();
newTx.begin();
List messages = newEm.createQuery("select m from Message m order by m.text asc").getResultList();
System.out.println( messages.size() + " message(s) found" );
for (Object m : messages) {
Message loadedMsg = (Message) m;
System.out.println(loadedMsg.getText());
}
newTx.commit();
newEm.close();
// Shutting down the application
emf.close();
}
}
e o persistence.xml:
org.hibernate.ejb.HibernatePersistence<class>hello.Message</class>
<properties>
<property name="hibernate.archive.autodetection"
value="class, hbm"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost/banco?autoReconnect=true"/>
<property name="hibernate.connection.username"
value="root"/>
<property name="hibernate.c3p0.min_size"
value="5"/>
<property name="hibernate.c3p0.max_size"
value="20"/>
<property name="hibernate.c3p0.timeout"
value="300"/>
<property name="hibernate.c3p0.max_statements"
value="50"/>
<property name="hibernate.c3p0.idle_test_period"
value="3000"/>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
ja coloquei o persitence em tudo q eh canto masi nao tem jeito… esse exemplo eh adaptado do Java persitence with hibernate…
alguem ja passou por isso? pode me dar uma luz?