Comprei um Ebook e estou executado o exemplo do livro com o seguinte codigo
:
Esta dando o seguinte erros :
EntityManagerFactory connot be resolved to a type
Persistence connot be resolved
1. public class PersistidorDeAutomovel {
2.
3. public static void main(String[] args) {
4. EntityManagerFactory emf =
5. Persistence.createEntityManager("default");
6. }
7.
8. }
persistence.xml
<http://www.guj.com.br/java/282196-jpa-iniciante#>
1. <?xml version="1.0" encoding="UTF-8"?>
2.
3. <persistence version="2.4"
4. xmlns="http://java.sun.com/xml/ns/persistence"
5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6. xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
7. http://java.sun.com/xml/ns/persistence/persistence_2_4.xsd">
8.
9. <persistence-unit name="default">
10. <properties>
11. <property name="javax.persistence.jdbc.driver"
12. value="com.mysql.jdbc.Driver" />
13. <property name="javax.persistence.jdbc.url"
14. value="jdbc:mysql://localhost/automoveis" />
15. <property name="javax.persistence.jdbc.password"
16. value="root" />
17. <property name="javax.persistence.jdbc.username"
18. value="password" />
19.
20. <property name="hibernate.dialect"
21. value="org.hibernate.dialect.MySQLInnoDBDialect" />
22.
23. <property name="hibernate.hbm2ddl.auto"
24. value="update" />
25.
26. </properties>
27. </persistence-unit>
28.
29. </persistence>
[As partes desta mensagem que não continham texto foram removidas]
Para upload/download de arquivos: http://www.yahoogroups.com/files/java-br
0 comentários:
Postar um comentário