Integration test for springboot with initalize query - spring-boot

I am going use an integration test in spring boot with in memory mysql database.But my test component in repository part query like:
#Query(
value = "SELECT order_id,title,description,requirement,salary,user_info.name,user_info.contact,date"+
" FROM job_order " +
" FULL JOIN user_info " +
" ON sender_id=user_info.id" +
" WHERE order_id= ?1 ;",nativeQuery = true
)
Response singlejob(int order_id);
My entrypoint is doing stuff on the job_order table.The query require two tables ,so i am trying to insert the user_info table and then test for the job_order.Then a write test like this:
#SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
#AutoConfigureMockMvc
#TestExecutionListeners(listeners = { SqlScriptsTestExecutionListener.class })
class OrderServiceApplicationTests {
#Autowired
private MockMvc mockMvc;
#Autowired
private ObjectMapper objectMapper;
#Autowired
private JobRepository jobRepository;
//#Sql("INSERT INTO user_info(name) VALUES \"alex\" ")
#Test
#Sql("{/resources/schema.sql}")
void shouldCreatePost() throws Exception {
JobOrder job=jobRepository.save(createjob());
String request=objectMapper.writeValueAsString(job);
mockMvc.perform(MockMvcRequestBuilders.post("/Job/Joborder")
.contentType(MediaType.APPLICATION_JSON)
.content(request))
.andExpect(status().is2xxSuccessful());
}
JobOrder createjob(){
JobOrder job=new JobOrder();
job.setTitle("Hiring software engineer");
job.setDescription("responsible for developing and maintaining mobile app");
job.setRequirement("Need to know basic sql springboot,2 years exp");
job.setSalary(234);
job.setOrder_id(1);
return job;
}
}
schema.sql:
INSERT INTO user_info (name) VALUES ('India');
and i got an error:
org.springframework.jdbc.datasource.init.CannotReadScriptException: Cannot read SQL script from class path resource [com/example/OrderService/{/resources/schema.sql}]
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:239)
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254)
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:54)
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.execute(ResourceDatabasePopulator.java:269)
at org.springframewo
My properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=***
spring.datasource.password=*******
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.defer-datasource-initialization=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.sql.init.mode=always
My Path:
I dont know what is the problem on my path.And i am wondering if there are problem on my test script or strategy

Path resource semantics should be followed when #Sql annotation is used. If you want to load the script file from the resources folder you should use classpath: reference:
#Sql(value = {"classpath:schema.sql"})

Related

Integration test in spring boot cant found the path of sql file

I am writing a integration test for rest api entry.The api require to initialize database before the test.However it gives an error which showing it cant find any path to my sql file.
#SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
#AutoConfigureMockMvc
#TestExecutionListeners(listeners = { SqlScriptsTestExecutionListener.class })
class OrderServiceApplicationTests {
#Autowired
private MockMvc mockMvc;
#Autowired
private ObjectMapper objectMapper;
#Autowired
private JobRepository jobRepository;
//#Sql("INSERT INTO user_info(name) VALUES \"alex\" ")
#Test
#Sql("{/resources/schema.sql}")
void shouldCreatePost() throws Exception {
JobOrder job=jobRepository.save(createjob());
String request=objectMapper.writeValueAsString(job);
mockMvc.perform(MockMvcRequestBuilders.post("/Job/Joborder")
.contentType(MediaType.APPLICATION_JSON)
.content(request))
.andExpect(status().is2xxSuccessful());
}
JobOrder createjob(){
JobOrder job=new JobOrder();
job.setTitle("Hiring software engineer");
job.setDescription("responsible for developing and maintaining mobile app");
job.setRequirement("Need to know basic sql springboot,2 years exp");
job.setSalary(234);
job.setOrder_id(1);
return job;
}
}
schema.sql:
INSERT INTO user_info (name) VALUES ('India');
and i got an error:
org.springframework.jdbc.datasource.init.CannotReadScriptException: Cannot read SQL script from class path resource [com/example/OrderService/{/resources/schema.sql}]
at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:239)
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:254)
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:54)
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.execute(ResourceDatabasePopulator.java:269)
at org.springframewo
My properties:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=***
spring.datasource.password=*******
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.defer-datasource-initialization=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.sql.init.mode=always
My Path:
I dont know what is the problem on my path.And i am wondering if there are problem on my test script or strategy
Several things are wrong with your #Sql("{/resources/schema.sql}").
the { and } do not belong into the path, why did you add it in the first place?
You don't need to include the /resources directory in the path. To find out what the path of your file is, open the target/test-classes and have a look. Everything that resides in the resources directory will be placed in the root directory. If your file was in resources/sql/test.sql it would be available under sql/test.sql.
Solution
#Sql("schema.sql")

Hibernate statistic different at runtime as on test

At runtime i'am sending get-request to my api and i can see, that hibernate executes 4 jdbc statements. One statement is a sql-join and second one is select-count for page-element and two other statements "hibernate fetch.subselects", which are for persistence-bag.
When I'am sending with MockMVC under WebapplicationContext get-request to my api to test, that it will be everytime 4 jdbc statements and not more, I am getting only two first jdbc-statements which I've described.
So how can I get during test-time the same amount of jdbc's like on runtime?
Controller:
#GetMapping({"/"})
public String links(#PageableDefault Pageable page,
Model model) {
Page<MyEntity> entity = service.fetchAllEntities(page);
List<Integer> totalPages = Arrays.asList(1,2)
model.addAttribute("entity",entity);
model.addAttribute("numbers",totalPages);
return "object/object_list";
}
Test-Controller
#ActiveProfiles("test")
#RunWith(SpringRunner.class)
#Transactional
public class AllControllersTransactionTest {
private MockMvc mockMvc;
#Autowired
private WebApplicationContext context;
private Statistics hibernateStatistic;
Session hibernateSession;
private EntityManager entityManager;
#Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(context)
.build();
entityManager = BeanUtil.getBeanFromContext(EntityManager.class);
hibernateSession = entityManager.unwrap(Session.class);
hibernateStatistic = hibernateSession.getSessionFactory().getStatistics();
hibernateStatistic.clear();
}
#Test
public void shouldReturnAllLinksWith5JDBCStatmentsAsAutheticated() throws Exception {
List<Integer> pages = Arrays.asList(new Integer[] {1,2});
MvcResult result = this.mockMvc.perform(get("/"))
.andDo(print())
.andExpect(status().isOk());
LOGGER.info("QUERIES: ", hibernateStatistic.getQueries());
assertEquals("SHOULD EXECUTED ONLY 4 JDBC STATMENTS", 4, hibernateStatistic.getQueryExecutionCount()); //At test-time, they are only two statments
}
}
UPDATE
I've switched off open-session-in-view in spring:
spring.jpa.open-in-view=false
Next point is, that i'am mapping my model into dto-object in my service-bean:
public Page<UserDTO> fetchAllLinksWithUsersCommentsVotes(Pageable pageable){
Page<Link> ln = linkRepository.findAll(pageable);
UserDTO.getMapDto(ln.getContent().get(0)); //additional two queries will be execued
UserDTO.getMapDto(ln.getContent().get(1)); //no queries will be executed
UserDTO.getMapDto(ln.getContent().get(2)); //no queries will be executed
ArrayList<UserDTO> users = ..//get users;
return new PageImpl<>(users, pageable, ln.getTotalElements());
}
When i'am executing
UserDTO.getMapDto(ln.getContent().get(0));
so i can see at runtime and during testtime,
that last two queries (persistence-bag with lazy-loading) will be executed.
Difference between runtime and testtime is, that during runtime hibernate shows 4 JDBC-Statments and on testtime only 2 JDBC-Statments by same-entries in the log (4 select-statments) .
So, why i can see 4 JDBC-Statments within log and runtime and testtime but i have different result within hibernate statistic on runtime and testtime.

#Transactional in Spring Boot - I believe prerequisites are covered (public, external invocation), but testing indicates no transaction

I'm trying to get a Kotlin function to operate transactionally in Spring Boot, and I've looked at several sources for information, such as https://codete.com/blog/5-common-spring-transactional-pitfalls/ and Spring #Transaction method call by the method within the same class, does not work?. I believe I have the prerequisites necessary for the #Transactional annotation to work - the function is public and being invoked externally, if my understanding is correct. My code currently looks like this:
interface CreateExerciseInstance {
operator fun invoke(input: CreateExerciseInstanceInput): OpOutcome<CreateExerciseInstanceOutput>
}
#Component
class CreateExerciseInstanceImpl constructor(
private val exerciseInstanceRepository: ExerciseInstanceRepository, // #Repository
private val activityInstanceRepository: ActivityInstanceRepository, // #Repository
private val exerciseInstanceStepRepository: ExerciseInstanceStepRepository // #Repository
) : CreateExerciseInstance {
#Suppress("TooGenericExceptionCaught")
#Transactional
override fun invoke(input: CreateExerciseInstanceInput): OpOutcome<CreateExerciseInstanceOutput> {
...
val exerciseInstanceRecord = ... // no in-place modification of repository data
val activityInstanceRecords = ...
val exerciseInstanceStepRecords = ...
return try {
exerciseInstanceRepository.save(exerciseInstanceRecord)
activityInstanceRepository.saveAll(activityInstanceRecords)
exerciseInstanceStepRepository.saveAll(exerciseInstanceStepRecords)
Outcome.Success(...)
} catch (e: Exception) {
Outcome.Failure(...)
}
}
}
My test currently looks like this:
#ExtendWith(SpringExtension::class)
#SpringBootTest
#Transactional
class CreateExerciseInstanceTest {
#Autowired
private lateinit var exerciseInstanceRepository: ExerciseInstanceRepository
#Autowired
private lateinit var exerciseInstanceStepRepository: ExerciseInstanceStepRepository
#Autowired
private lateinit var activityInstanceRepository: ActivityInstanceRepository
#Test
fun `does not commit to exercise instance or activity repositories when exercise instance step repository throws exception`() {
... // data setup
val exerciseInstanceStepRepository = mockk<ExerciseInstanceStepRepository>()
val exception = Exception("Something went wrong")
every { exerciseInstanceStepRepository.save(any<ExerciseInstanceStepRecord>()) } throws exception
val createExerciseInstance = CreateExerciseInstanceImpl(
exerciseInstanceRepository = exerciseInstanceRepository,
activityInstanceRepository = activityInstanceRepository,
exerciseInstanceStepRepository = exerciseInstanceStepRepository
)
val outcome = createExerciseInstance(...)
assert(outcome is Outcome.Failure)
val exerciseInstances = exerciseInstanceRepository.findAll()
val activityInstances = activityInstanceRepository.findAll()
assertThat(exerciseInstances.count()).isEqualTo(0)
assertThat(activityInstances.count()).isEqualTo(0)
}
}
The test fails with:
org.opentest4j.AssertionFailedError:
Expecting:
<1>
to be equal to:
<0>
but was not.
at assertThat(exerciseInstances.count()).isEqualTo(0). Is the function actually non-public or being invoked internally? Have I missed some other prerequisite?
This test doesn't say anything about your component not being transactional.
First, you create an instance yourself rather than using the one created by Spring. So Spring knows nothing about this instance, and can't possibly warp it into a transactional proxy.
Second, the component doesn't throw any runtime exception, So Spring doesn't rollback the transaction.

Spring Boot Application cannot run test cases involving Two Databases correctly - either get detached entities or no inserts

I am trying to write a Spring Boot app that talks to two databases - primary which is read-write, and secondary which is read only.
This is also using spring-data-jpa for the repositories.
Roughly speaking this giude describes what I am doing: https://www.baeldung.com/spring-data-jpa-multiple-databases
And this documentation from spring:
https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html#howto-two-datasources
I am having trouble understanding some things - I think about the transaction managers - which is making my program error out either during normal operation, or during unit tests.
I am running into two issues, with two different TransactionManagers that I do not understand well
1)
When I use JPATransactionManager, my secondary entities become detached between function calls. This happens in my application running in full Spring boot Tomcat, and when running the JUnit test as SpringRunner.
2)
When I use DataSourceTransactionManager which was given in some tutorial my application works correctly, but when I try to run a test case with SpringRunner, without running the full server, spring/hibernate will not perform any inserts or updates on the primaryDataSource.
--
Here is a snippet of code for (1) form a service class.
#Transactional
public List<PrimaryGroup> synchronizeAllGroups(){
Iterable<SecondarySite> secondarySiteList = secondarySiteRepo.findAll();
List<PrimaryGroup> allUserGroups = new ArrayList<PrimaryGroup>(0);
for( SecondarySite secondarySite: secondarySiteList){
allUserGroups.addAll(synchronizeSiteGroups( secondarySite.getName(), secondarySite));
}
return allUserGroups;
}
#Transactional
public List<PrimaryGroup> synchronizeSiteGroups(String sitename, SecondarySite secondarySite){
// GET all secondary groups
if( secondarySite == null){
secondarySite = secondarySiteRepo.getSiteByName(sitename);
}
logger.debug("synchronizeGroups started - siteId:{}", secondarySite.getLuid().toString());
List<SecondaryGroup> secondaryGroups = secondarySite.getGroups();// This shows the error because secondarySite passed in is detached
List<PrimaryGroup> primaryUserGroups = primaryGroupRepository.findAllByAppName(sitename);
...
// modify existingUserGroups to have new data from secondary
...
primaryGroupRepository.save(primaryUserGroups );
logger.debug("synchronizeGroups complete");
return existingUserGroups;
}
I am pretty sure I understand what is going on with the detached entities with JPATransactionManager -- When populateAllUsers calls populateSiteUser, it is only carrying over the primaryTransactionManager and the secondary one gets left out, so the entities become detached. I can probably work around that, but I'd like to see if there is any way to have this work, without putting all calls to secondary* into a seperate service layer, that returns non-managed entities.
--
Here is a snippet of code for (2) from a controller class
#GetMapping("synchronize/secondary")
public String synchronizesecondary() throws UnsupportedEncodingException{
synchronizeAllGroups(); // pull all the groups
synchronizeAllUsers(); // pull all the users
synchronizeAllUserGroupMaps(); // add the mapping table
return "true";
}
This references that same synchronizeAllGroups from above. But when I am useing DataSourceTransactionManager I do not get that detached entity error.
What I do get instead, is that the primaryGroupRepository.save(primaryUserGroups ); call does not generate any insert or update statement - when running a JUnit test that calls the controller directly. So when synchronizeAllUserGroupMaps gets called, primaryUserRepository.findAll() returns 0 rows, and same with primaryGroupRepository
That is to say - it works when I run this test case:
#RunWith(SpringRunner.class)
#SpringBootTest(classes=app.DApplication.class, properties={"spring.profiles.active=local,embedded"})
#AutoConfigureMockMvc
public class MockTest {
#Autowired
private MockMvc mockMvc;
#Test
public void shouldSync() throws Exception {
this.mockMvc.perform(get("/admin/synchronize/secondary")).andDo(print()).andExpect(status().isOk());
}
}
But it does not do any inserts or updates when I run this test case:
#RunWith(SpringRunner.class)
#SpringBootTest(classes=app.DApplication.class, properties={"spring.profiles.active=local,embedded"}, webEnvironment=WebEnvironment.MOCK)
#AutoConfigureMockMvc
public class ControllerTest {
#Autowired AdminController adminController;
#Test
public void shouldSync() throws Exception {
String o = adminController.synchronizesecondary();
}
}
Here are the two configuration classes
Primary:
#Configuration
#EnableTransactionManagement
#EntityScan(basePackageClasses = app.primary.dao.BasePackageMarker.class )
#EnableJpaRepositories(
transactionManagerRef = "dataSourceTransactionManager",
entityManagerFactoryRef = "primaryEntityManagerFactory",
basePackageClasses = { app.primary.dao.BasePackageMarker.class }
)
public class PrimaryConfig {
#Bean(name = "primaryDataSourceProperties")
#Primary
#ConfigurationProperties("app.primary.datasource")
public DataSourceProperties primaryDataSourceProperties() {
return new DataSourceProperties();
}
#Bean(name = "primaryDataSource")
#Primary
public DataSource primaryDataSourceEmbedded() {
return primaryDataSourceProperties().initializeDataSourceBuilder().build();
}
#Bean
#Primary
public LocalContainerEntityManagerFactoryBean primaryEntityManagerFactory(
EntityManagerFactoryBuilder builder,
#Qualifier("primaryDataSource") DataSource primaryDataSource) {
return builder
.dataSource(primaryDataSource)
.packages(app.primary.dao.BasePackageMarker.class)
.persistenceUnit("primary")
.build();
}
#Bean
#Primary
public DataSourceTransactionManager dataSourceTransactionManager( #Qualifier("primaryDataSource") DataSource primaryDataSource) {
DataSourceTransactionManager txm = new DataSourceTransactionManager(primaryDataSource);
return txm;
}
}
And Secondary:
#Configuration
#EnableTransactionManagement
#EntityScan(basePackageClasses=app.secondary.dao.BasePackageMarker.class ) /* scan secondary as secondary database */
#EnableJpaRepositories(
transactionManagerRef = "secondaryTransactionManager",
entityManagerFactoryRef = "secondaryEntityManagerFactory",
basePackageClasses={app.secondary.dao.BasePackageMarker.class}
)
public class SecondaryConfig {
private static final Logger log = LoggerFactory.getLogger(SecondaryConfig.class);
#Bean(name = "secondaryDataSourceProperties")
#ConfigurationProperties("app.secondary.datasource")
public DataSourceProperties secondaryDataSourceProperties() {
return new DataSourceProperties();
}
#Bean(name = "secondaryDataSource")
public DataSource secondaryDataSourceEmbedded() {
return secondaryDataSourceProperties().initializeDataSourceBuilder().build();
}
#Bean
public LocalContainerEntityManagerFactoryBean secondaryEntityManagerFactory(
EntityManagerFactoryBuilder builder,
#Qualifier("secondaryDataSource") DataSource secondaryDataSource) {
return builder
.dataSource(secondaryDataSource)
.packages(app.secondary.dao.BasePackageMarker.class)
.persistenceUnit("secondary")
.build();
}
#Bean
public DataSourceTransactionManager secondaryTransactionManager( #Qualifier("secondaryDataSource") DataSource secondaryDataSource) {
DataSourceTransactionManager txm = new DataSourceTransactionManager(secondaryDataSource);
return txm;
}
}
In my real application, the secondary data source - since it is read-only - is used during real run time, and during the unit test I am writing.
I have been having trouble getting spring to initialize both data sources, so I have not attached a complete example.
thanks for any insight people an give me.
Edit: I have read some things that say to use Jta Transaction Manager when using multiple databases, and I have tried that. I get an error when it tries to run the transaction on my second read-only database when I go to commit to the first database
Caused by: org.postgresql.util.PSQLException: ERROR: prepared transactions are disabled
Hint: Set max_prepared_transactions to a nonzero value.
In my case, I cannot set that, because the database is a read-only datbase provided by a vendor, we cannot change anything, and I really sho9udn't be trying to include this database as part of transactions, I just want to be able to call both databases in one service call.

Tables not created when running unit tests with test profile

For an unknown reason, my unit tests do not work anymore. All of a sudden the tables for my test database are not being created anymore.
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.tool.schema.internal.SchemaDropperImpl.applyConstraintDropping(SchemaDropperImpl.java:331) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:230) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126) [hibernate-core-5.2.14.Final.jar:5.2.14.Final]
...
Caused by: org.postgresql.util.PSQLException: ERROR: relation "app_user__user_group" does not exist
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284) ~[postgresql-9.4.1208-jdbc42-atlassian-hosted.jar:9.4.1208]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003) ~[postgresql-9.4.1208-jdbc42-atlassian-hosted.jar:9.4.1208]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200) ~[postgresql-9.4.1208-jdbc42-atlassian-hosted.jar:9.4.1208]
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424) ~[postgresql-9.4.1208-jdbc42-atlassian-hosted.jar:9.4.1208]
..
Let's just say that I didn't change anything, at least not to my best knowledge that should've changed that behavior, but that's just me and my relation with Spring.
So let's dump the necessary information:
#RunWith(SpringRunner.class)
#SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, properties = "spring.profiles.active=test")
public class AppUserRepositoryTest {
private final static Logger LOGGER = LogManager.getLogger(AppUserRepositoryTest.class);
#Autowired
private TestRestTemplate template;
private static String USERS_ENDPOINT = "http://localhost:8080/users/";
private static String GROUPS_ENDPOINT = "http://localhost:8080/groups/";
private static String USER_LOGIN = "http://localhost:8080/oauth/token/";
#Autowired
private WebApplicationContext wac;
#Autowired
private FilterChainProxy springSecurityFilterChain;
private MockMvc mockMvc;
#Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac)
.addFilter(springSecurityFilterChain).build();
LOGGER.info("Setup done.");
}
#Test
#DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
public void whenCreateAppUser() {
Client client = new Client();
AppUser appUser = client.registerUser("test#example.com", "password");
ResponseEntity<AppUser> appUserResponse = template.getForEntity(USERS_ENDPOINT + "1/", AppUser.class);
assertEquals("Username is incorrect. AppUser not created?",
appUser.getUsername(), appUserResponse.getBody().getUsername());
}
}
Here's application-test.properties - or at least the relevant part:
# Disable feature detection by this undocumented parameter. Check the org.hibernate.engine.jdbc.internal.JdbcServiceImpl.configure method for more details.
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false
# Because detection is disabled you have to set correct dialect by hand.
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect
spring.datasource.url=jdbc:postgresql://localhost/mahlzeit-test
spring.datasource.username=postgres
spring.datasource.password=root
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=create-drop
Any idea what the problem could be? Please let me know if you need further information and/or code.

Resources