Hibernate mostra sql e depois da erro como nao identificado

Nao sei pq, ele aparece que executo o codigo que gera as tabelas automatico, mais quando dou um insert, fala que nao possui a tabela. Observo no msyql e realmente nao criou a tabela… pq será ? Utilizo o macOs… o banco ta instalado e rodando…

Hibernate:

create table clube (
   id bigint not null auto_increment,
    nome varchar(255),
    porcentagemRake double precision,
    primary key (id)
) type=InnoDB

Hibernate:

create table GanhosSemanal (
   id bigint not null auto_increment,
    data datetime,
    ganhosClubeBuyInTicket double precision,
    ganhosClubeTaxa double precision,
    ganhosJogadorSeguro double precision,
    possuiPpst bit not null,
    clube_id bigint,
    primary key (id)
) type=InnoDB

Hibernate:

create table GanhosSemanal_PPST (
   GanhosSemanal_id bigint not null,
    listaPpst_id bigint not null
) type=InnoDB

Hibernate:

create table PPST (
   id bigint not null auto_increment,
    data datetime, 
    ganhosJogadorGeral double precision,
    clube_id bigint,
    ganhoSemanal_id bigint,
    primary key (id)
) type=InnoDB

Hibernate:

alter table GanhosSemanal_PPST 
   drop index UK_8i81ngtmd4vssefivgnh3l9rs

Hibernate:

alter table GanhosSemanal_PPST 
   add constraint UK_8i81ngtmd4vssefivgnh3l9rs unique (listaPpst_id)

Hibernate:

alter table GanhosSemanal 
   add constraint FKc5b5digqgf6246p2p3ijotm11 
   foreign key (clube_id) 
   references clube (id)

Hibernate:

alter table GanhosSemanal_PPST 
   add constraint FKk2wyi0vmxfon0qmxogkwv7v9k 
   foreign key (listaPpst_id) 
   references PPST (id)

Hibernate:

alter table GanhosSemanal_PPST 
   add constraint FKo084d7tne6eb434si96m631hr 
   foreign key (GanhosSemanal_id) 
   references GanhosSemanal (id)

Hibernate:

alter table PPST 
   add constraint FKq7ltj05x2pxrgjv0tg4s45heh 
   foreign key (clube_id) 
   references clube (id)

Hibernate:

alter table PPST 
   add constraint FK3c6jtqec4p5il4pg3u9w22s68 
   foreign key (ganhoSemanal_id) 
   references GanhosSemanal (id)

Hibernate:

insert
into
clube
(nome, porcentagemRake)
values
(?, ?)


Exception in thread “main” javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:802)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:778)
at br.com.mavenpoker.Util.GeraBancoUtil.main(GeraBancoUtil.java:34)
Caused by: org.hibernate.exception.SQLGrammarException: could not execute statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:200)
at org.hibernate.dialect.identity.GetGeneratedKeysDelegate.executeAndExtract(GetGeneratedKeysDelegate.java:57)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3152)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3756)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:84)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:645)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:282)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:263)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:317)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:330)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:123)
at org.hibernate.event.internal.DefaultMergeEventListener.saveTransientEntity(DefaultMergeEventListener.java:271)
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:243)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:175)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:70)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:102)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:791)
… 2 more
Caused by: java.sql.SQLSyntaxErrorException: Table ‘pkr.clube’ doesn’t exist
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1092)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1040)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1347)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1025)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)
… 21 more


Bloco de Citação

Bloco de Citação<? xml** version= *"1.0"* encoding= *"UTF-8"* ?>
< 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” xmlns= http://java.sun.com/xml/ns/persistence >
< persistence-unit name= “pkr” transaction-type= “RESOURCE_LOCAL” >
< properties >
< property name= “hibernate.dialect” value= “org.hibernate.dialect.MySQLInnoDBDialect” />
< property name= “javax.persistence.jdbc.driver”* value= “com.mysql.cj.jdbc.Driver” />
< property name= “javax.persistence.jdbc.url”* value= “jdbc:mysql://localhost:3306/pkr” />
< property name= “javax.persistence.jdbc.user”* value= “root” />
< property name= “javax.persistence.jdbc.password”* value= “12345” />
< property name= “hibernate.hbm2ddl.auto” value= “update” />
< property name= “hibernate.show_sql” value= “true” />
< property name= “hibernate.format_sql” value= “true” />
< property name= *“hibernate.hibernate.cache.use_query_cache” value= “true” />
</ properties >
</ persistence-unit >
</ persistence >



@Entity
@Table (name = “clube”)
public class Clube {
@Id
@GeneratedValue (strategy = GenerationType. IDENTITY )
private Long id;
@Column
private String nome;
@Column
private Double porcentagemRake;

bom dia fera

esse é o erro que vc colocou no post “Table ‘pkr.clube’ doesn’t exist” (tabela ‘pkr.clube’ não existe). Quando o hibernate tenta fazer um insert e a tabela não existe da erro de persistência mesmo, o que acontece é que você precisa declarar as classes de entidade dentro do “persistence.xml” se não o hibernate não toma conhecimento delas.

<? xml** version= *"1.0"* encoding= *"UTF-8"* ?>
< 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” xmlns= “http://java.sun.com/xml/ns/persistence” >
   < persistence-unit name= “pkr” transaction-type= “RESOURCE_LOCAL” >
      <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
      <class>pacote_onde_a_classe_esta.Clube</class>
      < properties >
         < property name= “hibernate.dialect” value= “org.hibernate.dialect.MySQLInnoDBDialect” />
         < property name= “javax.persistence.jdbc.driver”* value= “com.mysql.cj.jdbc.Driver” />
         < property name= “javax.persistence.jdbc.url”* value= “jdbc:mysql://localhost:3306/pkr” />
         < property name= “javax.persistence.jdbc.user”* value= “root” />
         < property name= “javax.persistence.jdbc.password”* value= “12345” />
         < property name= “hibernate.hbm2ddl.auto” value= “update” />
         < property name= “hibernate.show_sql” value= “true” /> 
         < property name= “hibernate.format_sql” value= “true” />
         < property name= *“hibernate.hibernate.cache.use_query_cache” value= “true” />
      </ properties >
   </ persistence-unit >
</ persistence >

Bloco de Citação
< persistence-unit name= “pkr” transaction-type= “RESOURCE_LOCAL” >
< provider >org.hibernate.jpa.HibernatePersistenceProvider</ provider >
< class >br.com.mavenpoker.Model.Clube</ class >
< class >br.com.mavenpoker.Model.PPST</ class >
< class >br.com.mavenpoker.Model.GanhosSemanal</ class >
< properties >

Fiz a alteraçao e continua … =/

Esse código está no github ??

Ve se consegue acesso.
Estou tentando usar a classe GeraBancoUtil , só pra teste, pra depois, que estiver salvando e acessando normal do Banco de dados, ae jogar no DAO generico e trabalhar com outras classes…

Tente trocar transaction-type por JTA

Bloco de Citação
< persistence-unit name= “pkr” transaction-type= “RESOURCE_LOCAL” >

< persistence-unit name= “pkr” transaction-type= “JTA

Apareceu outro erro quando coloco JTA

log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread “main” java.lang.ExceptionInInitializerError
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: pkr] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1336)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1262)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at br.com.mavenpoker.Util.GeraBancoUtil.(GeraBancoUtil.java:18)
Caused by: org.hibernate.HibernateException: DdlTransactionIsolatorJtaImpl could not locate TransactionManager to suspend any current transaction; base JtaPlatform impl (org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform@4b5a078a)?
at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.(DdlTransactionIsolatorJtaImpl.java:46)
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildDdlTransactionIsolator(JtaTransactionCoordinatorBuilderImpl.java:46)
at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getDdlTransactionIsolator(HibernateSchemaManagementTool.java:188)
at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.buildGenerationTargets(HibernateSchemaManagementTool.java:146)
at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:110)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:145)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73)
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:316)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:469)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1259)
… 4 more

OK retorna RESOURCE_LOCAL
Vamos tentar forçar a criação

< property name= “hibernate.hbm2ddl.auto” value= “create” />

Onde você esta rodando?

Maquina Local, maCos…

Criei as tabelas na mao, e executei o GeraBancoUtil ( q na verdade só insere um dado na tabela clube)

e inseriu normal.

< property name= “hibernate.hbm2ddl.auto” value= “create” />
coloquei update, pq acaba removendo e nao cria e da erro…

Hibernate:
insert
into
clube
(nome, porcentagemRake)
values
(?, ?)
Exception in thread “main” javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:802)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:778)
at br.com.mavenpoker.Util.GeraBancoUtil.main(GeraBancoUtil.java:34)
Caused by: org.hibernate.exception.SQLGrammarException: could not execute statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:200)
at org.hibernate.dialect.identity.GetGeneratedKeysDelegate.executeAndExtract(GetGeneratedKeysDelegate.java:57)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3152)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3756)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:84)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:645)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:282)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:263)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:317)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:330)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:123)
at org.hibernate.event.internal.DefaultMergeEventListener.saveTransientEntity(DefaultMergeEventListener.java:271)
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:243)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:175)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:70)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:102)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:791)
… 2 more
Caused by: java.sql.SQLSyntaxErrorException: Table ‘pkr.clube’ doesn’t exist
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1092)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1040)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1347)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1025)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197) … 21 more

o mais estranho, que ele executa o drop, ae nao executa o create depois… ae nao identifica as tabelas,

Onde esta o Jar do drive do MySQL?

estou fazendo as modificações pelo github, assim que terminar faço um pull request diretamente no repositório.

Não tem erros de configuração, só de implementação mesmo.

Pull request realizado. https://github.com/cmelchiaddes/pkr/pulls