-
Notifications
You must be signed in to change notification settings - Fork 19
Config/setting up persistance.xml #8
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||||||
| <persistence version="3.2" | ||||||
| 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_2.xsd"> | ||||||
| <persistence-unit name="jpa-hibernate-mysql"> | ||||||
| <properties> | ||||||
| <!-- Database connection settings --> | ||||||
| <property name="jakarta.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/test"/> | ||||||
| <property name="jakarta.persistence.jdbc.user" value="root"/> | ||||||
| <property name="jakarta.persistence.jdbc.password" value="root"/> | ||||||
| <!-- Automatically export the schema --> | ||||||
| <property name="jakarta.persistence.schema-generation.database.action" value="create"/> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Schema action "create" will drop all tables on every startup. The Consider these alternatives:
🔎 Suggested fix for development workflow- <property name="jakarta.persistence.schema-generation.database.action" value="create"/>
+ <property name="jakarta.persistence.schema-generation.database.action" value="update"/>For production, use: <property name="jakarta.persistence.schema-generation.database.action" value="validate"/>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| <!-- Echo all executed SQL to console //TODO: Set to false in production --> | ||||||
| <property name="hibernate.show_sql" value="true"/> | ||||||
| <property name="hibernate.format_sql" value="true"/> | ||||||
| <property name="hibernate.highlight_sql" value="true"/> | ||||||
| </properties> | ||||||
| </persistence-unit> | ||||||
| </persistence> | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove hardcoded database credentials immediately.
Committing database credentials to version control is a critical security vulnerability. The credentials are exposed in the repository history and accessible to anyone with repository access.
🔎 Recommended approaches to secure credentials
Option 1: Environment variables (recommended for this project)
Option 2: Separate properties file (not committed to git)
Create
src/main/resources/db.propertiesand add it to.gitignore:Then load these properties programmatically when creating the EntityManagerFactory.
Option 3: Use a template file
Commit
persistence.xml.templatewith placeholders and document in README how to create the actualpersistence.xmllocally.🤖 Prompt for AI Agents