0

I am very new to the ObjectDB. The reason I am trying to use this is to create desktop java application using embedded database. In other words, I ultimately want to give my friend a runnable jar file alone so he can access the database in javaFX application without bothering anything such as server.

According to the mannual, I have to use the EntityManagerFactory like this:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("$objectdb/db/points.odb");

The mannual says "The createEntityManagerFactory static method expects a persistence unit name as an argument, but when using ObjectDB, any valid database file path is also accepted."

So far, I created an Entity Class and then the tutorial suddenly introduced that. I am lost at the argument of the EntityManaferFacotory method. All I have is an Entity class. What is about the database file?

and would you give me an idea how to embed database into jar file? Like where to place certain file or certain way to put file path?

Rin
  • 99
  • 1
  • 3
  • 6

1 Answers1

1

The database file will be created automatically if it does not exist yet, so the parameter of createEntityManagerFactory could be simply a path to the database file, where $objectdb represents the ObjectDB home directory.

ObjectDB
  • 1,312
  • 8
  • 9
  • Thank you for the answer! So will it be embedded as long as it is located within the java project folder? – Rin Jun 10 '15 at 11:24
  • If the parameter is a path with no server then the database will be accessed directly, .i.e. in embedded mode rather than in client-server mode. See this documentation page for more details: http://www.objectdb.com/java/jpa/persistence/overview – ObjectDB Jun 10 '15 at 17:19