How to access database and run custom executable or query on it? after some search i found that i can use sessionFactory, but i have to force hibernate as data handler, well that make me worry if it have some bad effect or behavior in my complex part of application, depending on the way it links data together, or the way it fetches joined data and handles them... so i want to go with spring default... also if it doesn't preferred hibernate, it may mean that hibernate is slower. i want to access the online session (previously i used NHibernate on C#, and creating secondary session could be problematic), so i want to access exists session of database, beside when i use JpaRepository, and run the custom command on it. so i don't disturb other session, or locks :|
BTW i'm using HSQLDB for now...
Spring JDBC has a
DataSource
initializer feature. Spring Boot enables it by default and loads SQL from the standard locationsschema.sql
anddata.sql
(in the root of the classpath). In addition Spring Boot will load theschema-${platform}.sql
anddata-${platform}.sql
files (if present), where platform is the value ofspring.datasource.platform
, e.g. you might choose to set it to the vendor name of the database (hsqldb, h2, oracle, mysql, postgresql etc.).The script locations can be changed by settingspring.datasource.schema
andspring.datasource.data
, and neither location will be processed ifspring.datasource.initialize=false
.More here
If you put the hibernate jars in you classpath then Spring's autoconfiguration will take over and think that you wanna user Hibernate. So make sure you don't have those jars in your classpath.