Hibernate

2 respostas
P

Não consigo acessar atrvés do arquivo persistence.xml que está no diretoório META-INF

O que está de errado ;;;;???

alguém pode me ajudar ;…

abs

Exception in thread "main" javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265)
	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
	at br.com.modelo.model.Teste.main(Teste.java:13)
Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:70)
	at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:89)
	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:222)
	... 4 more
---

<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="local" transaction-type="RESOURCE_LOCAL">
    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
      <property name="hibernate.connection.driver_class"  value="com.mysql.jdbc.Driver" />
      <property name="hibernate.connection.url"     value="jdbc:mysql://localhost:3306/local;create=true" />
      <property name="hibernate.show_sql" value="true" />
      <property name="hibernate.connection.username" value="root" />
       <property name="hibernate.connection.password" value="root" />
      <!? Drop and re-create the database schema on startup ?>
      <property name="hibernate.hbm2ddl.auto" value="create" />
    </properties>
  </persistence-unit>
  <persistence-unit name="persistencia" transaction-type="RESOURCE_LOCAL">
    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
      <property name="hibernate.connection.driver_class"  value="com.mysql.jdbc.Driver" />
      <property name="hibernate.connection.url"     value="jdbc:mysql://localhost:3306/local;create=true" />
      <property name="hibernate.show_sql" value="true" />
      <property name="hibernate.connection.username" value="root" />
       <property name="hibernate.connection.password" value="root" />
      <!? Drop and re-create the database schema on startup ?>
      <property name="hibernate.hbm2ddl.auto" value="create" />
    </properties>
  </persistence-unit>
</persistence>


---


import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class Teste {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistencia");
     
	}

}


---

2 Respostas

LucianoM86

Posso estar enganado, mas não lembro de já ter visto essa tag…

<!? Drop and re-create the database schema on startup ?>

tenta fazer um teste tirando ela.

P

tirei e apareceu isso agora

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named local
Criado 26 de novembro de 2008
Ultima resposta 26 de nov. de 2008
Respostas 2
Participantes 2