Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Widfly apaga tabelas do Mysql

Bom dia , ao subir o servidor Wildfly ele apaga todas as tabelas do Mysql e recria do zero apagando todos os dados. Como faço para isso não acontecer(apagar os dados)

Obrigado

4 respostas

Boa tarde Sergio. Pode ser a configuração da jpa. Pode postar aqui para eu dar uma olhada?

Opa, obrigado Guilherme segue o persistence:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="casadocodigo-persistence-unit"
        transaction-type="JTA">
        <description>Forge Persistence Unit</description>
        <provider>org.hibernate.ejb.HibernatePersistence</provider>


        <jta-data-source>java:jboss/datasources/casadocodigoDS</jta-data-source>
        <properties>
            <property name="hibernate.hbm2ddl.auto" value="create-drop" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
        </properties>
    </persistence-unit>
</persistence>
solução!

Pessoal, para quem possa interessar é só alterar o value do hbm2ddl para "update" e dar um clean no projeto se necessário. Segue explicação:

<property name="hibernate.hbm2ddl.auto" value="update" />

This are the options and explanations:

validate | update | create | create-drop

Validate = will validate the schema that you have, and makes no changes to the database.

Update = will update the database if the schema is already there in the database.

Create = will create new database, removing existing schema if any

Create-drop = will create new database and drops it when the sessionFactory is destroyed.

Sergio, era isso mesmo e muito legal sua resposta! Ajudará muitos alunos!

Abraços e bons estudos

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software