Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Pessoal, podem dar um help? Acredito que esteja com algum problema no mapeamento.

Ao executar:

agendamentoEmailDao.listarAgendamentosEmail()

 org.h2.jdbc.JdbcSQLException: Table "AGENDAMENTOEMAIL" not found; SQL statement:
select agendament0_.id as id1_0_, agendament0_.assunto as assunto2_0_, agendament0_.email as email3_0_, agendament0_.enviado as enviado4_0_, agendament0_.mensagem as mensagem5_0

Ao executar :

salvarAgendamentoEmail()

07:28:42,934 ERROR [org.jboss.as.ejb3.invocation] (default task-2) WFLYEJB0034: EJB Invocation failed on component AgendamentoEmailBusiness for method public void br.com.alura.business.AgendamentoEmailBusiness.salvarAgendamentoEmail(br.com.alura.entity.AgendamentoEmail): javax.ejb.EJBTransactionRolledbackException: org.hibernate.PersistentObjectException: detached entity passed to persist: br.com.alura.entity.AgendamentoEmail

persistence.xml

<?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="agendamentoemail">
        <class>com.alura.entity.AgendamentoEmail</class>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/agendamentobd" />
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password" value="MINHA_SENHA)" />  
        </properties>
    </persistence-unit>
</persistence>

Meu agendamentoEmailBusiness

package br.com.alura.business;

import java.util.List;

import javax.ejb.Stateless;
import javax.inject.Inject;

import br.com.alura.dao.AgendamentoEmailDao;
import br.com.alura.entity.AgendamentoEmail;

@Stateless
public class AgendamentoEmailBusiness {

    @Inject
    private AgendamentoEmailDao agendamentoEmailDao;

    public List<AgendamentoEmail> listarAgendamentosEmail(){
        return agendamentoEmailDao.listarAgendamentosEmail();        
    }

    public void salvarAgendamentoEmail( AgendamentoEmail agendamentoEmail) {

        agendamentoEmail.setEnviado(false);
        agendamentoEmailDao.salvarAgendamentoEmail(agendamentoEmail);

    }

}

Schema: agendamentobd

script:

create table AgendamentoEmail (id integer primary key auto_increment, email varchar(20), enviado boolean , assunto varchar(20), mensagem varchar(20));
insert into AgendamentoEmail (id, assunto, email, enviado, mensagem) values (3, 'teste','teste', 0, 'teste');
1 resposta
solução!

Descobri!! Voltei ao curso de Java e JPA e descobri que era o persistence.xml que tava dando erro.

Segue a versão que funcionou:

<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="agendamentoemail">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>com.alura.entity.AgendamentoEmail</class>
        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/agendamentobd" />
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password" value="MINHA_SENHA" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
        </properties>
    </persistence-unit>    

</persistence>

Só levei duas semanas pra descobrir! É a vida. kkk