Hello, I have removed hibernate-annotations.jar, hibernate3.jar and hibernate-entitymanager.jar, and I have added hibernate-core-3.5.0-CR-2.jar, but now I have another error:
Quote:
Buildfile: C:\Documents and Settings\empalacios\workspaceManningJP\HelloWorldJPEM\build.xml
clean:
[delete] Deleting directory C:\Documents and Settings\empalacios\workspaceManningJP\HelloWorldJPEM\bin
[mkdir] Created dir: C:\Documents and Settings\empalacios\workspaceManningJP\HelloWorldJPEM\bin
compile:
[javac] Compiling 2 source files to C:\Documents and Settings\empalacios\workspaceManningJP\HelloWorldJPEM\bin
copymetafiles:
[copy] Copying 2 files to C:\Documents and Settings\empalacios\workspaceManningJP\HelloWorldJPEM\bin
run:
[java] Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named helloworld
[java] at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
[java] at hello.HelloWorld.main(Unknown Source)
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 1 second
and my persistence-unit is "helloworld", this is my persistence.xml:
Code:
<!-- La cabecera de este fichero declara el esquema que se va a utilizar, y que será
siempre el mismo, aunque se omita en el manual -->
<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_1_0.xsd"
version="1.0">
<persistence-unit name="helloworld">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- Not needed, Hibernate supports auto-detection in JSE
<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="org.hsqldb.jdbcDriver"/>
<property name="hibernate.connection.url"
value="jdbc:hsqldb:hsql://localhost"/>
<property name="hibernate.connection.username" value="sa"/>
<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.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
</persistence-unit>
</persistence>
and this is my HelloWorld.java:
Code:
package hello;
import java.util.*;
import javax.persistence.*;
public class HelloWorld {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
//Inicio del EntityManagerFactory, crea la unidad de persistencia
//Utilizando un hibernate.cfg.xml del primer HelloWorld, bastaría con: EntityManagerFactory emf = Persistence.createEntityManagerFactory("helloworld");
Map myProperties = new HashMap();
myProperties.put("hibernate.hbm2ddl.auto", "create-drop");
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("helloworld", myProperties);
//Primera unidad de trabajo
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
Message message = new Message("HelloWorld");
em.persist(message);
tx.commit();
em.close();
//Segunda unidad de trabajo
EntityManager newEm = emf.createEntityManager();
EntityTransaction newTx = newEm.getTransaction();
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();
//Cerrando la aplicación
emf.close();
}
}
Please, can you help me and tell me where is the error now?
Thank you very much