Franscis123$#
JCHJava Community | Help. Code. Learn.
•Created by Franscis123$# on 2/18/2025 in #java-help
Cannot invoke "jakarta.persistence.EntityManagerFactory.createEntityManager()" "this.emf" is null
I mapped my classes and transformed it in tables for my database. When I try to create a register I get this error. How I should to initialize emf?
PersistenceController
14 replies
JCHJava Community | Help. Code. Learn.
•Created by Franscis123$# on 2/3/2025 in #java-help
The collection of metamodel types is empty
I'm have a maven project with JPA and EclipseLink. When I run it don't generate the tables in the database. I have this output:
IceCreamShop/src/main/resources/META-INF/persistence.xml:
32 replies
JCHJava Community | Help. Code. Learn.
•Created by Franscis123$# on 1/30/2025 in #java-help
No Persistence provider for EntityManager named IceCreamShopPU
ActionJpaController:
40 replies
JCHJava Community | Help. Code. Learn.
•Created by Franscis123$# on 8/5/2024 in #java-help
How to check if a value coincide with any enum value?
I want to detect if a input values of a vector coincide with any value of a enum, I just got what detect if are entered in order, but I don't mind the order. (The same order what I declared the enum values).
```java
import java.util.Scanner;
public class EnumsNames{
Scanner key=new Scanner(System.in);
public void ENames(){
enum Names{
Alejandra,Leonardo,Rosa,Guillermo,Gabriel,Daniel,Luisa,Ludmila
}
String[] name=new String[8];
for(int n=0;n<name.length;n++){
boolean valid=false;
while(!valid){
System.out.println("Input a name:");
name[n]=key.next();
// In this if are my problem
if(name[n].equals(Names.values()[n].toString())){
valid=true;
}else{
System.out.println("Invalid name");
}
}
}
}
8 replies
JCHJava Community | Help. Code. Learn.
•Created by Franscis123$# on 7/20/2024 in #java-help
Is possible print e.g. "X²" instead of "X^2" but the exponent as a variable?
In Java using Intellij IDEA is possible to print a variable like this "X²" (being "2" the variable) instead of "X^2"?
11 replies
JCHJava Community | Help. Code. Learn.
•Created by Franscis123$# on 7/18/2024 in #java-help
In Java, how to print only the value instead of "OptionalDouble[value]"?"
I printing a OptionalDouble matrix, and in the print, instead of print only the variable value, print e.g. "OptionalDouble[2.0]". I only want to print the value (2.0 in this example) and not "OptionalDouble[2.0]".
The code:
```java
import java.util.Scanner;
import java.ultil.OptionalDouble;
Scanner key=new Scanner(System.in);
OptionalDouble[][] mat;
mat=new OptionalDouble[3][3];
String YorN;
for(int f=0;f<mat.length,f++){
for(int c=0;c<mat.length;c++){
System.out.print("Do you want insert a value? (Yes:Y / No:N)");
YorN=key.next;
if(YorN.equals("Y")||YorN.equals("y"){
mat[f][c]=OptionalDouble.of(key.nextDouble());
}
}
}
for(int f=0;f<mat.length,f++){
for(int c=0;c<mat.length;c++){
System.out.print(mat[f][c].toString());
}
}
7 replies
JCHJava Community | Help. Code. Learn.
•Created by Franscis123$# on 7/17/2024 in #java-help
Java don't let me to use isEmpty
I declared a OptionalDouble as a marix, and I can't to use a if with isEmpty for this:
if (polEXP_Lim[f][c].isEmpty()){
}
All of this obviously inside of two for's
Marks me the error in isEmpty.
A way to solve it or an alternative to isEmpty?
5 replies