-
Notifications
You must be signed in to change notification settings - Fork 2.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
SQL import script not loaded in neither profile (prod, dev, test) #7358
Comments
Could you provide a reproducer? Thanks! |
@gsmet: I prepared the sample so you can test every scenario I described. The only thing: run the postgres server (docker command in project's README) before starting the application. |
Thanks @kolorobot I'll take a look tonight |
Looking at this real quick, it seems like Also the runtime logs for Hibernate do show that |
I did find the same issue, until I've realized that Hibernate only runs the import file if the |
Same experience here...... had 1 file with tables creation and inserts , and I wanted to use the hibernate.creation=none and execute the import.sql ( I'm migrating SpringPetclinic into Quarkus spring extensions ) ..... and it doesnt read the file..... |
Still having this issue with Quarkus 2.5.1, all works fine iff %xxxx.quarkus.hibernate-orm.database.generation=create |
I am also having the same issue, any update about this issue? |
Well, it's not really a bug. In Hibernate ORM (and it has always been the case, I think), the import script is only executed if you create the schema (which makes sense as this script is supposed to import data, not do anything else). Now maybe we should have another feature to allow having a schema creation script that is executed always, where you could also have insert statements. |
Thanks for your quick response, what I am trying to do for my integration tests, is to execute a script after Hibernate ORM has set up all the database objects, according to this article: https://www.morling.dev/blog/quarkus-and-testcontainers, it seems to be supported, I tried both options create and drop-and-create, none of them worked. |
Yes, it should work. If it doesn't, you should probably put together a reproducer so that we can have a look. We have thorough tests for that as it kept getting broken so we really need a reproducer to have a look. |
The thing is that, if we have a DB with data, we cannot asume to drop the entire DB and populate it again, it would be interesting to just execute a .sql script that make some modifications although the generation is equal to "none". I agree, it is not a bug. But it would be interesting to decide when to run the import sql script |
I'm not sure what the purpose of this feature is, so that makes me uncomfortable. I think it warrants some discussion:
|
In case someone wants to contribute something trivial in this area to ORM we can take it in consideration (I haven't fully understood the details), but for anything beyond we should indeed encourage using flyway or liquibase. We certainly don't want to expand features in ORM to the point of competing with other libraries which already do a fine job at addressing such goals. +1 to know more about the use case :) In general I'd recommned: use Hibernate ORM's schema management for quick experiments in development cycles on an empty database; as soon as the DB content actually becomes important to the point you don't want to drop it constantly, it also means your scripts need to be written with greater care. The other tools offer better management abilities for multiple, more complex scripts and safeguards. |
My Use Case: I am using Flyway with Quarkus to manage the DB schema migration. I have that working and the tables are correctly instantiated at startup. I would like the I'll probably press on with changing how I was planning to the tests as this is not a major issue for me, but thought I would see if my use-case might help with the rationale for a change. 👍🏻 |
Ok, it seems everyone who commented here just wants to be able to import data on startup in dev/test mode, even with ORM schema management disabled, and independently of other tools such as Flyway. This makes sense, but that's what #21866 is about, and #21866 explains the use case more clearly, right in the issue description. So I'll close this ticket as a duplicate of #21866. If you think that's wrong, ping me and we'll see what needs to be done. |
Duplicates #21866 |
Neither of the scenarios works for me as it goes to loading the SQL file:
import.sql
file insrc/main/resources
in profile DEV, TEST, PRODimport.sql
file insrc/test/resources
in profile DEV, TEST, PRODI also tried all the properties:
%dev.quarkus.hibernate-orm.sql-load-script = db/data-test.sql
%test.quarkus.hibernate-orm.sql-load-script = db/data-test.sql
When no file is present I get the exception that the property is not pointing to the actual file:,
but when I fix the path the file is not loaded anyways. I even added some no-SQL statement hoping to see errors, but nothing happens.
Environment (please complete the following information):
java -version
: JDK 11Additional context
Related to:
#3661
#6545
#7290
The text was updated successfully, but these errors were encountered: