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

Examples: Consider persistence.xml as an example to show value of GenAI #143

Open
jwmatthews opened this issue Apr 3, 2024 · 0 comments

Comments

@jwmatthews
Copy link
Member

Below is a contender for an example to surface to show the potential of how GenAI can help an end user beyond ~simple string substitutions and start to get into larger changes that leverage deeper knowledge.

https://github.com/konveyor-ecosystem/coolstore/blob/mixtral_april_2/src/main/resources/META-INF/persistence.xml.llm_result.md


Model ID: ibm-mistralai/mixtral-8x7b-instruct-v01-q

Reasoning

  1. The first issue to address is to update the XML schema namespace and version number for the persistence unit. This is because Java EE has been superseded by Jakarta EE, which uses different namespaces and version numbers.

  2. The second issue to address is to move the persistence configuration from an XML file to a properties file. This is because Quarkus uses a centralized configuration system, which allows for easier management and maintenance of configuration settings.

Updated File

<persistence version="3.0"
             xmlns="https://jakarta.ee/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="
        https://jakarta.ee/xml/ns/persistence
        https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
    <persistence-unit name="primary">
        <jta-data-source>java:jboss/datasources/CoolstoreDS</jta-data-source>
        <properties>
            <property name="jakarta.persistence.schema-generation.database.action" value="none"/>
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.use_sql_comments" value="true" />
            <property name="hibernate.jdbc.use_get_generated_keys" value="false" />
        </properties>
    </persistence-unit>
</persistence>

Additional Information

It is important to note that the updated file still references the java:jboss/datasources/CoolstoreDS JNDI name, which may not be valid in a Quarkus environment. This JNDI name should be updated to the correct name for the Quarkus environment. Additionally, the persistence configuration should be moved to a properties file, as recommended in Issue 8.

Here is an example of how the persistence configuration can be moved to a properties file:

  1. Create a new file named application.properties in the src/main/resources directory.
  2. Add the following configuration settings to the application.properties file:
quarkus.datasource.jdbc.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
quarkus.datasource.username=sa
quarkus.datasource.password=sa
quarkus.hibernate-orm.database.generation=none
quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.log.format-sql=true
quarkus.hibernate-orm.log.use-sql-comments=true
quarkus.hibernate-orm.jdbc.get-generated-keys=false
  1. Remove the <persistence> tag and its contents from the persistence.xml file.
  2. Update the persistence.xml file to reference the application.properties file:
<persistence version="3.0"
             xmlns="https://jakarta.ee/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="
        https://jakarta.ee/xml/ns/persistence
        https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
    <persistence-unit name="primary"
                      configuration-file="application.properties">
    </persistence-unit>
</persistence>
  1. Update the application.properties file to reference the correct JNDI name for the Quarkus environment.

By following these steps, the Java EE persistence configuration can be successfully migrated to a Quarkus environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant