I wanted to use objectdb on my spring boot app.
Here is what i have tried :
package com.manage.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import java.util.Properties;
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = "com.manage.jpa", // your Spring Data JPA repos
entityManagerFactoryRef = "entityManagerFactory",
transactionManagerRef = "transactionManager"
)
public class ObjectDbConfig {
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setPersistenceUnitName("objectdbPU");
// emf.setPackagesToScan("com.example.jpa", "com.other.entities", "com.manage.jpa");
emf.setPackagesToScan("com.manage.jpa");
emf.setPersistenceProviderClass(com.objectdb.jpa.Provider.class);
Properties jpa = new Properties();
// Embedded file DB (use an absolute path)
// for making new odb file:
// java -jar explorer-2.9.4.jar /mnt/disk1/DB/mydb.odb
jpa.setProperty("javax.persistence.jdbc.url", "objectdb:/mnt/disk1/DB/deepassets.odb");
// For in-memory tests: objectdb:mem:test.odb
// For server mode: objectdb://127.0.0.1:6136/deepassets.odb;user=...;password=...
// (Optional) any extra ObjectDB props:
// jpa.setProperty("objectdb.temp.no-detach", "true");
emf.setJpaProperties(jpa);
return emf;
}
@Bean
public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
return new JpaTransactionManager(emf);
}
} for config file i have specified on jvm param
-Dobjectdb.conf=F:/Files/Works/DeepAssets/objectdb.conf
Current basic config
<objectdb>
<general>
<temp path="$temp/ObjectDB" threshold="64mb" />
<network inactivity-timeout="0" />
<url-history size="50" user="true" password="true" />
<log path="$objectdb/log/" max="8mb" stdout="true" stderr="false" />
<log-archive path="$objectdb/log/archive/" retain="90" />
<logger name="*" level="info" />
</general>
<database>
<size initial="256kb" resize="256kb" page="2kb" />
<recovery enabled="true" sync="false" path="." max="128mb" />
<recording enabled="false" sync="false" path="." mode="write" />
<locking version-check="true" />
<processing cache="64mb" max-threads="10" synchronized="false" />
<query-cache results="32mb" programs="500" />
<extensions drop="temp,tmp" />
<activation code="xxxx-xxxx-xxxx-xxxx-xxxx" />
</database>
<entities>
<enhancement agent="true" reflection="warning" />
<cache ref="weak" level2="0mb" />
<persist serialization="false" />
<cascade-persist always="auto" on-persist="false" on-commit="true" />
<dirty-tracking arrays="false" />
</entities>
</objectdb>
Even though i have site license , software throws exception :
Caused by: com.objectdb.o.UserException: Too many persistable types (>10) - exceeds evaluation limit
And there is no tutorial how to use this on spring boot with license as param ?
I am currently trying to migrate my mariadb server to objectdb but its pain for me now ?
Also enchancer on gradle
tasks.register('objectdbEnhance', JavaExec) {
group = 'build'
description = 'Run ObjectDB Enhancer on compiled classes'
// Enhancer must see compiled classes + ObjectDB on the classpath
classpath = sourceSets.main.runtimeClasspath
mainClass = 'com.objectdb.Enhancer'
// Use your package pattern here (from your Maven snippet it was "point.*")
// Enhances these packages only (no subpackages):
args 'com.manage.jpa.*', 'com.manage.jpa.inventory.*' , 'com.manage.jpa.inventory.type.*' , 'com.manage.jpa.init.*'
}
// Run enhancer after classes are compiled (before jar/bootJar)
tasks.named('classes') {
finalizedBy tasks.named('objectdbEnhance')
}
my all jpa entity packages :
'com.manage.jpa.*', 'com.manage.jpa.inventory.*' , 'com.manage.jpa.inventory.type.*' , 'com.manage.jpa.init.*'
Do i need to pass all subpackages one by one ?
or
When we do :
emf.setPackagesToScan("com.manage.jpa");
it also scans subdirectory packages ?
for also
com.objectdb.Enhancer
args 'com.manage.jpa.*', 'com.manage.jpa.inventory.*' , 'com.manage.jpa.inventory.type.*' , 'com.manage.jpa.init.*'
on
application.properties
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration server.servlet.encoding.charset=UTF-8 server.servlet.encoding.enabled=true server.servlet.encoding.force=true spring.jpa.open-in-view=false
