Hibernate no Excludes

Asked

Viewed 93 times

1

Good night, you guys... I’m learning hibernate and I had a problem:

I was able to insert, retrieve the BD data... I had a setback that I fixed by adding the following command line in the execution settings (RUN):

--add-modules java.xml.bind

but at the time of exclusion I had this setback!

follows my code:

package aplication;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import Dominio.Pessoa;

public class Programa {

    public static void main(String[] args) {

        EntityManagerFactory emf = Persistence.createEntityManagerFactory("exemplo-jpa");
        EntityManager em = emf.createEntityManager();

        Pessoa p = em.find(Pessoa.class, 1);

        em.remove(p);

        System.out.println("Pronto!");
        em.close();
        emf.close();
    }

}

in the BD I have the record, where Hibernate looks for the ID 1 that is this record below:

1 - #[email protected] - somethings

when I run the program it does not elxclui and appears 4 warnigs:

WARNING: An illegal Reflective access Operation has occurred WARNING: Illegal Reflective access by javassist.util.proxy.Securityactions (file:/C:/Ws/Aulajpa/lib/javassist-3.20.0-GA.jar) to method java.lang.Classloader.defineClass(java.lang.String,byte[],int,int,java.security.Protectiondomain) WARNING: Please consider Reporting this to the maintainers of javassist.util.proxy.Securityactions WARNING: Use --illegal-access=warn to enable warnings of further illegal Reflective access Operations WARNING: All illegal access Operations will be denied in a Future release

put the command shown in Warning in the execution configuration:

--illegal-access=warn

he returned only a Warning:

WARNING: Illegal Reflective access by javassist.util.proxy.Securityactions (file:/C:/Ws/Aulajpa/lib/javassist-3.20.0-GA.jar) to method java.lang.Classloader.defineClass(java.lang.String,byte[],int,int,java.security.Protectiondomain)

then searching better found the same error and the resolution would be the following command:

--add-opens java.base/java.lang=ALL-UNNAMED

beauty... I circled, and there was no warning, but it didn’t erase from my comic!

I’m using JDK 10...

am downloading the latest stable version of Hibernate that supports JDK version 8+ to see if it is not incompatibility!

someone would know to tell me what is going on?

thanks!!!

1 answer

1


Try adding a em.flush(); after the em.remove(p);.

As for these warnings, they are the result of the concept of modularization introduced in Java 9. Many tool developers using Reflection were very dissatisfied with these changes that ended up causing several unexpected problems. Despite that, at least for now, you don’t have to worry about those warnings.

  • Really... the flush or the commit would solve my case!!! Thanks again for the force! The hint is that the command "-add-Opens java.base/java.lang=ALL-UNNAMED" set in the eclipse 'run' settings removes those warnings I got! thanks

Browser other questions tagged

You are not signed in. Login or sign up in order to post.