Use metamodels in tests [SOLVED]

plugins
hibernate

(José Luiz Abreu Cardoso Junior) #1

Hi I tried to use hibernate-jpamodelgen in my gradle project, when I generate my metamodels and run my application works fine, but when I try run my tests I get a follow error:

Note: Hibernate JPA 2 Static-Metamodel Generator 5.4.0.Final
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\RotaDeterminada_.java:11: error: duplicate class: br.com.serversocket.dao.model.RotaDeterminada_
public abstract class RotaDeterminada_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\RastreadorComandoHistorico_.java:10: error: duplicate class: br.com.serversocket.dao.model.RastreadorComandoHistorico_
public abstract class RastreadorComandoHistorico_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\Cliente_.java:9: error: duplicate class: br.com.serversocket.dao.model.Cliente_
public abstract class Cliente_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\Parametro_.java:13: error: duplicate class: br.com.serversocket.dao.model.Parametro_
public abstract class Parametro_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\DadoLidoDiario_.java:11: error: duplicate class: br.com.serversocket.dao.model.DadoLidoDiario_
public abstract class DadoLidoDiario_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\IdentificacaoMotorista_.java:10: error: duplicate class: br.com.serversocket.dao.model.IdentificacaoMotorista_
public abstract class IdentificacaoMotorista_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\CercaVirtual_.java:10: error: duplicate class: br.com.serversocket.dao.model.CercaVirtual_
public abstract class CercaVirtual_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\Veiculo_.java:11: error: duplicate class: br.com.serversocket.dao.model.Veiculo_
public abstract class Veiculo_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\DadoLido_.java:11: error: duplicate class: br.com.serversocket.dao.model.DadoLido_
public abstract class DadoLido_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\AlertaDisparado_.java:10: error: duplicate class: br.com.serversocket.dao.model.AlertaDisparado_
public abstract class AlertaDisparado_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\UltDadoLido_.java:12: error: duplicate class: br.com.serversocket.dao.model.UltDadoLido_
public abstract class UltDadoLido_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\Auditoria_.java:10: error: duplicate class: br.com.serversocket.dao.model.Auditoria_
public abstract class Auditoria_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\Motorista_.java:10: error: duplicate class: br.com.serversocket.dao.model.Motorista_
public abstract class Motorista_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\PontoCercaVirtual_.java:9: error: duplicate class: br.com.serversocket.dao.model.PontoCercaVirtual_
public abstract class PontoCercaVirtual_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\PontoControle_.java:9: error: duplicate class: br.com.serversocket.dao.model.PontoControle_
public abstract class PontoControle_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\PontoRotaDeterminada_.java:9: error: duplicate class: br.com.serversocket.dao.model.PontoRotaDeterminada_
public abstract class PontoRotaDeterminada_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\RespostaComando_.java:12: error: duplicate class: br.com.serversocket.dao.model.RespostaComando_
public abstract class RespostaComando_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\Alerta_.java:11: error: duplicate class: br.com.serversocket.dao.model.Alerta_
public abstract class Alerta_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\MotoristaIdentificacaoMotorista_.java:10: error: duplicate class: br.com.serversocket.dao.model.MotoristaIdentificacaoMotorista_
public abstract class MotoristaIdentificacaoMotorista_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\CondicaoAlerta_.java:10: error: duplicate class: br.com.serversocket.dao.model.CondicaoAlerta_
public abstract class CondicaoAlerta_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\DadoLidoDiarioPK_.java:10: error: duplicate class: br.com.serversocket.dao.model.DadoLidoDiarioPK_
public abstract class DadoLidoDiarioPK_ {
^
A:\eclipse\ServerSocketARA\build\classes\java\main\br\com\serversocket\dao\model\DadoLidoPK_.java:10: error: duplicate class: br.com.serversocket.dao.model.DadoLidoPK_
public abstract class DadoLidoPK_ {
^
22 errors

How can I use metamodes in my tests , I tried to use plugins and eclipse configuration, but I always get this error

[Edited]

I solved my problem withou use some plugin to generate a metamodels, In my case I use a eclipse to generate:

  • right click in project > properties > java compiler:
    check the option “Enable project specific settings”

  • Access inside “java compiler” a “Annotation processing” and check the option “Enable project specific settings”, “Enable annotation processing” and “Enable processing in editor”

  • In “Generated source directory” and “Generated test source directory” DON’T CHANGE THE DEFAULT OPTION, let “Generated source directory” = “.apt_generated” and “Generated test source directory” = “.apt_generated_tests” ( I got errors when I changed to my src/main/java and src/test/java)

Access option “Factory Path”, inside “Annotation processing” check “Enable project specific settings” and add a jar hibernate-jpamodelgen-x.x.x.jar