-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring Boot running data.sql before creating entities in presence of schema.sql #9048
Comments
I'm having a similar issue where Spring Boot Starter Version
pom.xml
|
Are you also using |
Currently the With hibernate:
Without hibernate:
This are of the code is unfortunately quite difficult to change without causing side effects. I don't think we'll be able to do anything in the 1.5.x line. I'd suggest you either try manually adding the create table commands for the entities in |
I was using both |
For now I have renamed the
|
@ConsciousObserver, I changed Due to log scripts execution order is correct:
Could you try it and give a response about results? |
@akanurlanopop , Thanks for response.
I don't want to make an entry for it inside I hope it make things clearer. If you make an entry of |
It looks like this issue would be addressed with what I am trying to do in #9528 |
There is a sample using Eclipselink at https://github.com/srinivasnagesh/spring-data |
The current behaviour is intended (see #1115) so I am not sure that if we can fix it. |
It doesn't look like we can, at least not without dragging Hibernate into the Spring Security-triggered part of the initialisation, similar to what would happen if someone tried to use a JPA-based user details service. |
I'm trying to insert some rows in my entities for testing on developer machine using
H2
Database. I'm usingdata.sql
for this.It works fine, entities are created and then
data.sql
is run to insert data in the tables produced by the entities.However I need to create some other tables for which there are no entity classes, so I'm using
schema.sql
for those. Here's the issue, as soon as I addschema.sql
to the project, Spring Boot runsdata.sql
before creating entities, which ends inTable not found exception
.It works fine if I replace
data.sql
withimport.sql
, it's run after the entities are created.However
h2
configuration is supposed to run only when testing, for that I have a maven profile which activates aspring.datasource.platform = h2
, to loadschema-h2.sql
anddata-h2.sql
.import.sql
doesn't work with the platform.So the issue is that
data.sql
is being run before entities are created only whenschema.sql
is present.Here's the Github repository for reproducing the issue
Without any platform
https://github.com/ConsciousObserver/SpringBootSchemaSqlIssue.git
With h2 platform (It's another branch
platform-h2
in the above repository)https://github.com/ConsciousObserver/SpringBootSchemaSqlIssue/tree/platform-h2
Stackoverflow
http://stackoverflow.com/questions/43692115/spring-boot-running-data-sql-before-creating-entities-in-presence-of-schema-sql
Thanks
The text was updated successfully, but these errors were encountered: