0

in the main method:

Iam only trying to store some objects in objectdb file in the root directory I want to know why the field in insurance class is not located in the class

package com.example.medicalcenter;

import com.example.medicalcenter.model.Insurance;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import java.io.IOException;

public class Run extends Application {


@Override
public void start(Stage stage) throws IOException {
    FXMLLoader fxmlLoader = new FXMLLoader(Run.class.getResource("patient.fxml"));
    Scene scene = new Scene(fxmlLoader.load(), 900, 600);
    stage.setTitle("Hello!");
    stage.setScene(scene);
    stage.show();

    EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("$objectdb/db/d.odb");
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    Insurance i = new Insurance("i1", 88f);
    entityManager.persist(i);

}

public static void main(String[] args) {
    launch();
}
}

Iam trying to use objectdb with maven project and this error keeps appearing. what I am doing is adding Insurance object to the database

Caused by: com.objectdb.o.UserException: Failed to locate field field com.example.medicalcenter.model.Insurance.percentage using reflection

Insurance class

@Entity public class Insurance {

@Id@GeneratedValue
private int id;

@Column(name="name")
private String name;

@Column(name="percentage")
private float percentage;

public Insurance() {
}

public Insurance(String name, float percentage) {
    this.name = name;
    this.percentage = percentage;
}

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public float getPercentage() {
    return percentage;
}

public void setPercentage(float percentage) {
    this.percentage = percentage;
}


}
  • Could you please post a minimal working example that demonstrates the issue? If possible using the format on https://www.objectdb.com/database/post. – ObjectDB Mar 14 '22 at 11:40
  • yes I will provide the full main class code – Adam Bazzal Mar 14 '22 at 11:47
  • No obvious issue is seen in the posted code so maybe the exception is related to the way in which the code is run. Anyway, this is still not a complete (but minimal) runnable program, so it may be difficult to help you. – ObjectDB Mar 14 '22 at 17:02

0 Answers0