I need to store a restaurant in a object oriented database with a name and a list of employees and products so when I create one of the latter I need a name an enum (3 categories) and a price.
Exception in thread "main" java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.lang.String java.lang.Enum.name accessible: module java.base does not "opens java.lang" to unnamed module @418e7838
By the way, i am using JDK 16.0.2 and db4o dependencies.
Here is my main class, it works and do the menu correctly:
public class Principal {
private static final String NOMBRE_BBDD = "restaurante.oo";
public static void main(String[] args) {
ObjectContainer db = crearDBOO();
int o;
do{
o = mostrarMenu();
tratarMenu(o, db);
}while(o != 8);
}
When I have try to store a class with an enum attribute, it is not able to access the object, code below:
public static void registrarBar(ObjectContainer db) {
String nombreRestaurante = "RestAccdat";
Restaurante bar = new Restaurante(nombreRestaurante);
bar.annadirEmpleado(new Empleado("Ivan", "Morales", "Mellado", "12341234Z"));
bar.annadirProducto(new Producto("Agua", Categoria.BEBIDA, 1));
bar.annadirProducto(new Producto("Ensalada", Categoria.COMIDA, 4.50));
bar.annadirProducto(new Producto("Pastel vegano", Categoria.POSTRE, 2.75));
db.store(bar);
System.out.println("Restaurante " + nombreRestaurante + " registrado con éxito.");
}
The Enum class:
public enum Categoria {
COMIDA, BEBIDA, POSTRE
}
public static ObjectContainer crearDBOO() {
return Db4oEmbedded.openFile(Db4oEmbedded.newConfiguration(), NOMBRE_BBDD);
}
My english level is not too great, anyway thankful for your answer and time.