Good night guys ... I'm learning Hibernate and had a problem:
I was able to insert, retrieve the DB data ... I had a setback that I corrected by adding the following command line in the RUN settings:
--add-modules java.xml.bind
But at the time of deleting I had this setback!
follow 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 BD I have the record, where Hibernate searches for ID 1 which is this record below:
1 - Someone's name - Someone
When you run the program it does not work and 4 warnigs appear:
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
I put the command shown in the warning in the configuration of the execution:
--illegal-access=warn
it returned only one 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)
After searching better I found the same error and the resolution would be the following command:
--add-opens java.base/java.lang=ALL-UNNAMED
Beauty ... I rode, and there was no Warning, but it did not erase from my BD!
I'm using JDK 10 ...
I'm downloading the latest stable version of Hibernate that supports JDK version 8+ to see if it's not incompatible!
Would anyone know to tell me what's going on?
Thank you!