Home » Support » Forum » Groovy JPA example

Groovy JPA example

#1

I've been using Groovy with ObjectDb, just thought I'd post a short snippet to show how easy this is to do.

The following script (which is one import and one statement) will open a database, run a query and print some results.

---------------------------------------------------------------

import javax.persistence.Persistence

Persistence
.createEntityManagerFactory ("../db1.odb")
.createEntityManager()
.createQuery ("SELECT u FROM User u")
.getResultList()
.each {
    println it
}
#2

Nice. Thanks for sharing it.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

Is there a preferred/recommended way to configure DataSource.groovy to connect to the ObjectDB database? As far as I gather, ObjectDB doesn't have the necessary drivers .

#4

ObjectDB doesn't have a JDBC driver, so you cannot configure a JDBC based data source.

You can connect ObjectDB from Groovy as specified in #1 above, or using a persistence.xml file.

Any Groovy library that supports JPA should also work with ObjectDB. If a driver is required you can specify a dummy data source driver (e.g. of another database), and it will be ignored, as long as the connection to ObjectDB is properly set in a persistence.xml file.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#5

As of 2010, there were plans to make that driver (http://www.objectdb.com/database/forum/271). Any progress since then? Are there any plans to make a Hibernate Dialect?

#6

A JDBC driver for ObjectDB could be a nice to have feature, but it is currently not in a high priority on our road map.

What do you mean by making a Hibernate dialect? In order to connect Hibernate to ObjectDB?

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login