0
I’m trying to set up a Maven project in Eclipse with Hibernate and H2 Database. So I’m trying to understand the persistence.xml settings, which I had to create.
One question is: do I need to include the classes I’m going to map in this persistence.xml? I took an example from the internet that has:
<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_2_0.xsd"
version="2.0">
<persistence-unit name="tarefas">
<!-- provedor/implementacao do JPA -->
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<!-- entidade mapeada -->
<class>br.com.caelum.tarefas.modelo.Tarefa</class>
<properties>
<!-- dados da conexao -->
<property name="javax.persistence.jdbc.driver"
value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://localhost/fj21" />
<property name="javax.persistence.jdbc.user"
value="root" />
<property name="javax.persistence.jdbc.password"
value="<SENHA DO BANCO AQUI>" />
<!-- propriedades do hibernate -->
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<!-- atualiza o banco, gera as tabelas se for preciso -->
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
It has an attribute/tag "class" that indicates the Java class to be mapped. I have to do this with all classes in my project?:
2- Another question is: if the above answer is yes, how does it work to indicate the relative path of the class relative to the location of my persistence.xml?
For example: see where . class and persistence.xmlareare in my project. How I point out the location of . class in persistence attributes?