Skip to content
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

Add an Hibernate ORM codestart #20879

Merged
merged 1 commit into from
Nov 15, 2021
Merged

Conversation

loicmathieu
Copy link
Contributor

No description provided.

@quarkus-bot quarkus-bot bot added area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE labels Oct 19, 2021
@loicmathieu loicmathieu force-pushed the hibernate-codestart branch 3 times, most recently from a811d16 to d353d27 Compare October 20, 2021 10:08
@loicmathieu loicmathieu marked this pull request as ready for review October 20, 2021 10:09
@loicmathieu
Copy link
Contributor Author

Hibernate ORM codestart.
It will create a simple JPA entity, and import.sql that creates 3 entities inside the DB and a unit test that inject an entity manager and list the existing entities.

@FroMage @Sanne is it OK so we can move on to the more complex and debatable 'with Panacge' one ?

@ia3andy
Copy link
Contributor

ia3andy commented Oct 20, 2021

@loicmathieu will the import.sql work with any type of db?

@loicmathieu
Copy link
Contributor Author

@loicmathieu will the import.sql work with any type of db?

I think so as it's standard SQL with no reserved word in it, I think. But maybe @Sanne knows better.
I can remove it and insert items inside the unit tests.

@quarkus-bot
Copy link

quarkus-bot bot commented Oct 20, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building d353d27

Status Name Step Failures Logs Raw logs
Devtools Tests - JDK 11 Build Failures Logs Raw logs
Devtools Tests - JDK 11 Windows Build Failures Logs Raw logs
Gradle Tests - JDK 11 Build Failures Logs Raw logs

Full information is available in the Build summary check run.

Failures

⚙️ Devtools Tests - JDK 11 #

- Failing: integration-tests/devtools 

📦 integration-tests/devtools

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testGradle(String)[1] line 77 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testRunTogetherCodestartsJava line 60 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testGradleKotlinDSL(String)[1] line 84 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testGradle(String)[1] line 77 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testRunTogetherCodestartsJava line 60 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testGradleKotlinDSL(String)[1] line 84 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

📦 integration-tests/devtools/target/quarkus-codestart-build-test/project-maven-java-c104dc43-0be3-4b5c-981c-7b5ffaa9edde

org.acme.HelloGrpcServiceTest.testHello - More details - Source on GitHub

java.lang.RuntimeException: 
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#configurationDescriptorBuilding threw an exception: io.quarkus.runtime.configuration.ConfigurationException: Model classes are defined for the default persistence unit, but no default datasource was found. The default EntityManagerFactory will not be created. To solve this, configure the default datasource. Refer to https://quarkus.io/guides/datasource for guidance.

⚙️ Devtools Tests - JDK 11 Windows #

- Failing: integration-tests/devtools 

📦 integration-tests/devtools

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testGradle(String)[1] line 77 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testRunTogetherCodestartsJava line 60 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testGradleKotlinDSL(String)[1] line 84 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testGradle(String)[1] line 77 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testRunTogetherCodestartsJava line 60 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartBuildIT.testGradleKotlinDSL(String)[1] line 84 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: 

expected: 0

📦 integration-tests/devtools/target/quarkus-codestart-build-test/project-maven-java-78cb4975-169b-417a-abb5-b36c36e4d717

org.acme.GreetingResourceTest.testHelloEndpoint - More details - Source on GitHub

java.lang.RuntimeException: 
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#configurationDescriptorBuilding threw an exception: io.quarkus.runtime.configuration.ConfigurationException: Model classes are defined for the default persistence unit, but no default datasource was found. The default EntityManagerFactory will not be created. To solve this, configure the default datasource. Refer to https://quarkus.io/guides/datasource for guidance.

⚙️ Gradle Tests - JDK 11 #

- Failing: integration-tests/gradle 

📦 integration-tests/gradle

io.quarkus.gradle.GrpcMultiModuleQuarkusBuildTest.testProtocErrorOutput line 39 - More details - Source on GitHub

org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:40)

@loicmathieu
Copy link
Contributor Author

@ia3andy the build fails because I didn't add any datasource to the quickstart test. Should I disable the codestartTest.buildAllProjects(); or should I add an SQL extension (like H2) ?

@ia3andy
Copy link
Contributor

ia3andy commented Oct 20, 2021

@ia3andy the build fails because I didn't add any datasource to the quickstart test. Should I disable the codestartTest.buildAllProjects(); or should I add an SQL extension (like H2) ?

I am not sure :-/

@Sanne
Copy link
Member

Sanne commented Oct 20, 2021

@loicmathieu will the import.sql work with any type of db?

I think so as it's standard SQL with no reserved word in it, I think. But maybe @Sanne knows better. I can remove it and insert items inside the unit tests.

Indeed it looks like standard SQL but it won't work on DBs which don't support sequences.

@loicmathieu
Copy link
Contributor Author

Well I didn't think about databases that didn't support sequences.
Is it very common so we should remove the import.sql or is it rare so a comment on the file is enough?

@loicmathieu
Copy link
Contributor Author

MySql didn't support sequences so I'll remove the import.sql file and I create the items manually.

@ia3andy
Copy link
Contributor

ia3andy commented Oct 20, 2021

@loicmathieu you don't have to delete it, just detect which db is selected using the list of extension, if you don't know, you keep it commented. wdyt?

@loicmathieu
Copy link
Contributor Author

@ia3andy it may be difficult to list the db that support/didn't support sequences, and how would we treat 'other' ? And if we comment it the proposed unit test will not work.
I think it's best to remove it, or hardcode the id (but in this case you will not be able to create an entity as it will clash with the manually inserted lines).

@ia3andy
Copy link
Contributor

ia3andy commented Oct 21, 2021

@ia3andy it may be difficult to list the db that support/didn't support sequences, and how would we treat 'other' ? And if we comment it the proposed unit test will not work. I think it's best to remove it, or hardcode the id (but in this case you will not be able to create an entity as it will clash with the manually inserted lines).

So keep the import.sql file but comment the lines and remove the test I would suggest

@loicmathieu
Copy link
Contributor Author

@ia3andy the test is the way to show how to use Hibernate ORM (inject and EM and work with it) so it should stay.
A commented file is not very usefull, I can keep it with all lignes commented but I really think we should keep the test.

@ia3andy
Copy link
Contributor

ia3andy commented Oct 21, 2021

@loicmathieu how will the test work without any data?

@loicmathieu
Copy link
Contributor Author

@ia3andy the test is really to show how to use a JPA entity for someone how don't know, most of the time it will be deleted and replaced by a REST endpoint, a reactive messaging method or a main.

In the test I will create three entity, persist them and retrieve them. Not a good unit test but a way to show how to use Hibernate ORM.

@ia3andy
Copy link
Contributor

ia3andy commented Oct 21, 2021

TBH I would not keep the test if it's meant to be deleted.. the initial code is not here to teach or show anything (the guide and quickstart are here for this). It's meant for people who already know how to use it and like having a head start.

@loicmathieu
Copy link
Contributor Author

So there is no point of having anything for Hibernate ORM as it will always be deleted.
Honestly, only creating a dump entity provides nothing for me.
If we didn't show that to use it we need to inject the EntityManager somewhere I don't see the point.

I updated my proposal with an import.sql with everything commented and a test that show the usage.

@ia3andy
Copy link
Contributor

ia3andy commented Nov 5, 2021

@loicmathieu failure seems unrelated..

Copy link
Contributor

@ia3andy ia3andy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @loicmathieu.. I am not sure if we should iterate on this PR with new commits for panache et reactive or create new PRs. I believe we should be fine with multiple PRs.

@loicmathieu
Copy link
Contributor Author

I can provide a Kotlin version tomorrow so we can merge this one with it.
I'll provide separate PR for the other extension.

@ia3andy
Copy link
Contributor

ia3andy commented Nov 8, 2021

@loicmathieu maybe it would be easier to:

  1. Make it "generic" and used by all the target extensions
  2. Add Kotlin

WDYT?

@loicmathieu
Copy link
Contributor Author

I don't think it's feasible to make it a generic one as the Panache version will be different, in fact all versions will be different as the javadoc contains the way to use it.

@ia3andy
Copy link
Contributor

ia3andy commented Nov 8, 2021

I don't think it's feasible to make it a generic one as the Panache version will be different, in fact all versions will be different as the javadoc contains the way to use it.

by generic I meant that it works with the different cases by altering the content depending on the selection. I didn't mean we we should have a "generic" content which fits all cases.

@loicmathieu
Copy link
Contributor Author

@ia3andy I still thinks this will be too much work for almost no benefits, each extension will share very little code so almost all lines will be templated. This would just add complexity

@ia3andy
Copy link
Contributor

ia3andy commented Nov 9, 2021

@loicmathieu I think we can separate reactive from the others, but hibernate and hibernate with panache may be selected together in the list, right? The generic approach let us make sure we don't have both in the same project while in the end only panache is needed..

@ia3andy
Copy link
Contributor

ia3andy commented Nov 9, 2021

ex:
hibernate + panache = panache entity
hibernate = hibernate entity
panache = panache entity

@loicmathieu
Copy link
Contributor Author

@ia3andy well, yes, this was my plan, conditionaly add different body to the MyEntity file when Panache is selected. I tought you mean having a base file that is modified via template.
When I'll implement the Panache codestart I'll modify this one to add the conditional stuff.

@ia3andy
Copy link
Contributor

ia3andy commented Nov 9, 2021

@ia3andy well, yes, this was my plan, conditionaly add different body to the MyEntity file when Panache is selected. I tought you mean having a base file that is modified via template. When I'll implement the Panache codestart I'll modify this one to add the conditional stuff.

ok cool :)

@loicmathieu
Copy link
Contributor Author

@ia3andy I added the Kotlin version. Please make a final review before merging this one; I'll then create the others for Panache/reactive/mongo.

@quarkus-bot
Copy link

quarkus-bot bot commented Nov 9, 2021

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building 45ee91d

Status Name Step Failures Logs Raw logs
Gradle Tests - JDK 11 Windows Build Failures Logs Raw logs
Native Tests - Windows - hibernate-validator Build Failures Logs Raw logs

Full information is available in the Build summary check run.

Failures

⚙️ Gradle Tests - JDK 11 Windows #

- Failing: integration-tests/gradle 

📦 integration-tests/gradle

io.quarkus.gradle.devmode.InjectQuarkusAppPropertiesDevModeTest.main line 19 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Condition with lambda expression in io.quarkus.test.devmode.util.DevModeTestUtils that uses java.util.function.Supplier, java.util.function.Supplierjava.util.concurrent.atomic.AtomicReference, java.util.concurrent.atomic.AtomicReferencejava.lang.String, java.lang.Stringboolean was not fulfilled within 1 minutes.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:164)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)

⚙️ Native Tests - Windows - hibernate-validator #

- Failing: integration-tests/hibernate-validator 

📦 integration-tests/hibernate-validator

Failed to execute goal io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:build (default) on project quarkus-integration-test-hibernate-validator: Failed to build quarkus application

* }
*/
@Entity
class MyKotlinEntity {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to use a kotlin data object?

@ia3andy
Copy link
Contributor

ia3andy commented Nov 10, 2021

@loicmathieu could you investigate the gradle dev mode test to find out it it's related to the codestart?

Maybe you should rebase from main?

@loicmathieu
Copy link
Contributor Author

@ia3andy as it's only on Windows, only on Gradle, not related to codestart I think this is safe to merge.

@ia3andy
Copy link
Contributor

ia3andy commented Nov 10, 2021

@loicmathieu I would feel better if the CI is green, could you rebase from main (this error happened already before on this PR, so it should have been fixed on main in the meantime)

@quarkus-bot
Copy link

quarkus-bot bot commented Nov 10, 2021

Failing Jobs - Building 4ead0fe

Status Name Step Failures Logs Raw logs
Native Tests - Windows - hibernate-validator Build Failures Logs Raw logs

Failures

⚙️ Native Tests - Windows - hibernate-validator #

- Failing: integration-tests/hibernate-validator 

📦 integration-tests/hibernate-validator

Failed to execute goal io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:build (default) on project quarkus-integration-test-hibernate-validator: Failed to build quarkus application

@loicmathieu
Copy link
Contributor Author

@ia3andy the last CI runs failed on native image test for Hiberate validator, I can see how it can be related to my PR.

@ia3andy
Copy link
Contributor

ia3andy commented Nov 12, 2021

I agree, just we should find out why this test is failing (so it doesn't bother every PRs).. @gsmet any thoughts

@ia3andy
Copy link
Contributor

ia3andy commented Nov 15, 2021

Ok it seems those tests are flaky: #20495
There is an ongoing discussion on zulip.

@ia3andy ia3andy merged commit 20ab3f5 into quarkusio:main Nov 15, 2021
@quarkus-bot quarkus-bot bot added this to the 2.6 - main milestone Nov 15, 2021
@loicmathieu loicmathieu deleted the hibernate-codestart branch December 10, 2021 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants