ObjectDB ObjectDB

Spring 4 setup

#1

Can someone provide an example of setup ObjectDB embeded to be used with Spring4?

Existing examples is like for Spring3 and I can't figure how to use ObjecDB in Spring tutorial:

https://spring.io/guides/gs/accessing-data-jpa/

 

Thanx.

edit
delete
#2

This tutorial uses Spring Boot and Spring JPA Data, so hidden default configuration applies (using Hibernate with the H2 database).

To use the tutorial with ObjectDB you will have to add the following:

In the pom.xml file under dependencies:

      <dependency>
          <groupId>com.objectdb</groupId>
          <artifactId>objectdb</artifactId>
          <version>2.5.6</version>
      </dependency>

In the pom.xml file under repositories:

      <repository>
           <id>objectdb</id>
           <name>ObjectDB Repository</name>
           <url>http://m2.objectdb.com</url>
      </repository>

In the Application class:

    @Bean
    JpaVendorAdapter JpaVendorAdapter() {
        return new AbstractJpaVendorAdapter() {
            @Override
            public PersistenceProvider getPersistenceProvider() {
                return new com.objectdb.jpa.Provider();
            }
           
            @Override
            public Map<String,?> getJpaPropertyMap() {
                return Collections.singletonMap(
                    "javax.persistence.jdbc.url", "test.odb");
            }
        };
    }
ObjectDB Support
edit
delete
#3

I am using Spring Boot too. I have 2 questions for the answer.

1. I have to add h2 dependency to my pom file, otherwise I will get some exception like:

'Cannot determine embedded database driver class for database type NONE'

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

2. The entity object can not extend org.springframework.data.jpa.domain.AbstractPersistable<Long>, otherwise I will get below error. I think the error is caused by generic extending.

Caused by: com.objectdb.o.UserException: Unsupported auto value type java.io.Serializable for field org.springframework.data.jpa.domain.AbstractPersistable.id
at com.objectdb.o.MSG.d(MSG.java:62)
at com.objectdb.o.MDF.T(MDF.java:640)
at com.objectdb.o.ANM.ac(ANM.java:761)
at com.objectdb.o.ANT.W(ANT.java:982)
at com.objectdb.o.ANT.V(ANT.java:879)
at com.objectdb.o.SCM.r(SCM.java:305)
at com.objectdb.o.SCM.r(SCM.java:208)
at com.objectdb.o.SCM.r(SCM.java:208)
at com.objectdb.o.TYS.n(TYS.java:294)
at com.objectdb.o.TYM.ae(TYM.java:521)
at com.objectdb.o.TYM.ac(TYM.java:467)
at com.objectdb.o.TYM.ao(TYM.java:788)
at com.objectdb.jpa.MetamodelImpl.obtainType(MetamodelImpl.java:269)
at com.objectdb.jpa.MetamodelImpl.managedType(MetamodelImpl.java:149)
... 53 more

Do you have a demo code on the Github to let use fully understand how should we use ObjectDB with latest version of Spring Boot?

edit
delete
#4

It is unclear why you need to specify h2. I think that in the tutorial of #1 with the adjustment of #2 it was not necessary. Assuming you do not use h2, maybe your application uses some default setting of Spring Framework that uses Hibernate + H2.

Regarding your second question, it is indeed unrelated to this thread, so good that you moved it to a new forum thread.

Note: See an update on this forum thread.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.