Metodo main and JUnit does not run on the console

0

I'm using Hibernate version 2.1 JPA version 5, and when I run both the main method and JUnit, nothing appears on the console not even some error. The client class and address contains your ids.

Neither System appears on the console.     System.out.println ("Test");

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
xmlns="http://xmlns.jcp.org/xml/ns/persistence" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence 
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">

<persistence-unit name="PedidoPU">
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

    <properties>
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://127.0.0.1:3306/cursojavaee" />
        <property name="javax.persistence.jdbc.user" value="root" />
        <property name="javax.persistence.jdbc.password" value="root" />
        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />

        <property name="hibernate.hbm2ddl.auto" value="create" />
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
    </properties>
</persistence-unit>

Hibernate

<!-- Núcleo do Hibernate -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>5.2.10.Final</version>
        <scope>compile</scope>
    </dependency>

    <!-- Implementação de EntityManager da JPA -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>5.2.10.Final</version>
        <scope>compile</scope>
    </dependency>

Test

public class Test {

public static void main(String[] args) {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("PedidoPU");
    EntityManager em = emf.createEntityManager();

    EntityTransaction trx = em.getTransaction();
    trx.begin();

    Cliente cliente = new Cliente();
    cliente.setNome("Paulo da Paz");
    cliente.setEmail("[email protected]");
    cliente.setDocumentoReceitaFederal("000.000.000-00");
    cliente.setTipo(TipoPessoa.FISICA);

    Endereco endereco = new Endereco();
    endereco.setLogradouro("Rua dos Anjos Branco");
    endereco.setComplemento("APTO 001");
    endereco.setNumero("111");
    endereco.setCidade("Luziânia");
    endereco.setUf("GO");
    endereco.setCep("72800000");
    endereco.setCliente(cliente);

    cliente.getEnderecos().add(endereco);

    em.persist(cliente);

    trx.commit();
}

Customer

@Entity
@Table(name = "cliente")
public class Cliente implements Serializable {

private static final long serialVersionUID = 1L;

private Long id;
private String nome;

@Id
@GeneratedValue
public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

get and set to name

Address

@Entity
@Table(name = "endereco")
public class Endereco implements Serializable {

private static final long serialVersionUID = 1L;

private Long id;
private String logradouro;
private String numero;
private String complemento;
private String cidade;
private String uf;
private String cep;
private Cliente cliente;

@Id
@GeneratedValue
public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

all get and set

    
asked by anonymous 26.05.2018 / 19:02

0 answers