-
Notifications
You must be signed in to change notification settings - Fork 19
Config/database #2
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
41721bf
4ba2a40
2a9c6e7
d316237
47b435f
b10491a
d845da2
36ccaa0
0e31491
656239b
ec32612
f5e3512
3949abc
452b39f
70e0f70
20ed6f8
4d1286a
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,17 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <module version="4"> | ||
| <component name="FacetManager"> | ||
| <facet type="jpa" name="JPA"> | ||
| <configuration> | ||
| <setting name="validation-enabled" value="true" /> | ||
| <datasource-mapping> | ||
| <factory-entry name="jpa-hibernate-mysql" /> | ||
| </datasource-mapping> | ||
| <naming-strategy-map> | ||
| <unit-entry name="jpa-hibernate-mysql" /> | ||
| </naming-strategy-map> | ||
| <deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" /> | ||
| </configuration> | ||
| </facet> | ||
| </component> | ||
| </module> |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||||||
| services: | ||||||||||
| mysql: | ||||||||||
| image: mysql:9.5.0 | ||||||||||
| container_name: jpa-mysql-db | ||||||||||
| environment: | ||||||||||
| MYSQL_PASSWORD: root | ||||||||||
| MYSQL_ROOT_PASSWORD: root | ||||||||||
|
Comment on lines
+6
to
+7
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. Avoid hardcoding credentials in docker-compose.yml for template projects. Since this is a template repository, hardcoded credentials like "root"/"root" will be inherited by all projects created from this template. Consider using environment variable placeholders or documenting that users should customize these values. Apply this diff to use environment variables with defaults: - MYSQL_PASSWORD: root
- MYSQL_ROOT_PASSWORD: root
+ MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-changeme}And add a 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| MYSQL_DATABASE: invoice-db | ||||||||||
|
|
||||||||||
| ports: | ||||||||||
| - "3306:3306" | ||||||||||
|
|
||||||||||
| volumes: | ||||||||||
| - mysql-data:/var/lib/mysql | ||||||||||
|
|
||||||||||
| volumes: | ||||||||||
| mysql-data: | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,28 @@ | ||
| package org.example; | ||
|
|
||
| import jakarta.persistence.EntityManager; | ||
| import org.example.entity.User; | ||
| import org.example.repository.UserRepository; | ||
| import org.example.service.UserService; | ||
| import org.example.util.JpaUtil; | ||
|
|
||
| public class App { | ||
| public static void main(String[] args) { | ||
| System.out.println("Hello There!"); | ||
| try (EntityManager em = JpaUtil.getEntityManager()) { | ||
|
|
||
| UserRepository userRepository = new UserRepository(em); | ||
| UserService userService = new UserService(userRepository); | ||
|
|
||
| User user = new User("testUser"); | ||
|
|
||
| //Operation 1 | ||
| userService.createUser(user); | ||
|
|
||
| User saved = userService.getUserByUsername("testUser"); | ||
| System.out.println(saved); | ||
|
Comment on lines
+21
to
+22
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# First, let's find the repository files
echo "=== Finding UserRepository ==="
fd -e java | xargs grep -l "class UserRepository" 2>/dev/null | head -20
echo -e "\n=== Finding User entity ==="
fd -e java | xargs grep -l "class User" 2>/dev/null | head -20Repository: ithsjava25/ithsjava25-java-project-jpa-maven-java-template Length of output: 369 🏁 Script executed: #!/bin/bash
# Get the getUserByUsername implementation
echo "=== UserRepository.getUserByUsername implementation ==="
rg "getUserByUsername" -A 5 --type java
echo -e "\n=== User entity primary key and structure ==="
rg -A 20 "class User" --type java | head -50Repository: ithsjava25/ithsjava25-java-project-jpa-maven-java-template Length of output: 4959 Critical: getUserByUsername implementation uses em.find() incorrectly. The Replace with a JPQL query: public User getUserByUsername(String username) {
TypedQuery<User> query = em.createQuery(
"SELECT u FROM User u WHERE u.username = :username",
User.class
);
query.setParameter("username", username);
return query.getSingleResult();
}🤖 Prompt for AI Agents |
||
|
|
||
| //Operation 2 | ||
| userService.deleteUserById(saved.getId()); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package org.example.entity; | ||
|
|
||
| import jakarta.persistence.*; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @Entity | ||
| @Table(name = "users") | ||
| public class User { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.UUID) | ||
| private UUID id; | ||
|
|
||
| @Column | ||
| private String username; | ||
|
|
||
|
|
||
| public User(String username){ | ||
| this.username = username; | ||
| } | ||
|
|
||
| public User() { | ||
|
|
||
| } | ||
|
|
||
| public UUID getId() { | ||
| return id; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,77 @@ | ||||||||||||||||||||||||||||||||||
| package org.example.repository; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import jakarta.persistence.EntityManager; | ||||||||||||||||||||||||||||||||||
| import jakarta.persistence.EntityManagerFactory; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||||||||||
| import java.util.Optional; | ||||||||||||||||||||||||||||||||||
| import java.util.function.Function; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| public abstract class BaseRepository <T, ID> { | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| private final EntityManagerFactory emf; | ||||||||||||||||||||||||||||||||||
| protected final Class <T> entityClass; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| protected BaseRepository(EntityManagerFactory emf, Class<T> entityClass) { | ||||||||||||||||||||||||||||||||||
| this.emf = emf; | ||||||||||||||||||||||||||||||||||
| this.entityClass = entityClass; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| protected <R> R runInTransaction(Function<EntityManager, R> action) { | ||||||||||||||||||||||||||||||||||
| EntityManager em = emf.createEntityManager(); | ||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||
| em.getTransaction().begin(); | ||||||||||||||||||||||||||||||||||
| R result = action.apply(em); | ||||||||||||||||||||||||||||||||||
| em.getTransaction().commit(); | ||||||||||||||||||||||||||||||||||
| return result; | ||||||||||||||||||||||||||||||||||
| } catch (Exception e) { | ||||||||||||||||||||||||||||||||||
| if (em.getTransaction().isActive()) em.getTransaction().rollback(); | ||||||||||||||||||||||||||||||||||
| throw new RuntimeException("Transaction failed for " + entityClass.getSimpleName(), e); | ||||||||||||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||||||||||||
| em.close(); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| protected <R> R executeRead(Function<EntityManager, R> action) { | ||||||||||||||||||||||||||||||||||
| EntityManager em = emf.createEntityManager(); | ||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||
| return action.apply(em); | ||||||||||||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||||||||||||
| em.close(); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| public void save(T entity) { | ||||||||||||||||||||||||||||||||||
| runInTransaction(em -> { | ||||||||||||||||||||||||||||||||||
| if (em.contains(entity)) { | ||||||||||||||||||||||||||||||||||
| em.merge(entity); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| em.persist(entity); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+53
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. Fix the save logic: em.contains() always returns false. The Choose one of these solutions: Option 1 (Recommended): Always use merge public void save(T entity) {
runInTransaction(em -> {
- if (em.contains(entity)) {
- em.merge(entity);
- } else {
- em.persist(entity);
- }
+ em.merge(entity);
return null;
});
}Option 2: Check if entity has ID (requires getter method) public void save(T entity) {
runInTransaction(em -> {
- if (em.contains(entity)) {
- em.merge(entity);
+ if (hasId(entity)) {
+ em.merge(entity);
} else {
em.persist(entity);
}
return null;
});
}Note: Option 2 requires implementing a 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| public void delete(T entity) { | ||||||||||||||||||||||||||||||||||
| runInTransaction(em -> { | ||||||||||||||||||||||||||||||||||
| em.remove(em.contains(entity) ? entity : em.merge(entity)); | ||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| public Optional<T> findById(ID id) { | ||||||||||||||||||||||||||||||||||
| return executeRead(em -> Optional.ofNullable(em.find(entityClass, id))); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| public List<T> findAll() { | ||||||||||||||||||||||||||||||||||
| return executeRead(em -> | ||||||||||||||||||||||||||||||||||
| em.createQuery("SELECT e FROM " + entityClass.getSimpleName() + " e", entityClass) | ||||||||||||||||||||||||||||||||||
| .getResultList() | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+77
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
echo "=== Checking for classes extending BaseRepository ==="
rg "extends.*BaseRepository" --type java -A 2
echo -e "\n=== Finding all repository files ==="
fd -e java -path "*/repository/*" | head -20
echo -e "\n=== All repository class definitions ==="
fd -e java -path "*/repository/*" --exec grep -H "class.*Repository" {} \;Repository: ithsjava25/ithsjava25-java-project-jpa-maven-java-template Length of output: 590 🏁 Script executed: #!/bin/bash
echo "=== Examining BaseRepository usage (imports) ==="
rg "BaseRepository" --type java
echo -e "\n=== Checking transaction management patterns ==="
rg "getTransaction\(\)|runInTransaction|executeRead" --type javaRepository: ithsjava25/ithsjava25-java-project-jpa-maven-java-template Length of output: 1817 🏁 Script executed: #!/bin/bash
echo "=== UserRepository implementation ==="
cat -n src/main/java/org/example/repository/UserRepository.java
echo -e "\n=== All Java files in repository directory ==="
ls -la src/main/java/org/example/repository/Repository: ithsjava25/ithsjava25-java-project-jpa-maven-java-template Length of output: 1434 BaseRepository is unused and UserRepository lacks transaction error handling.
More critically, Refactor one of the following:
Additionally, consider moving transaction management to the service layer rather than the repository layer for better separation of concerns. |
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||||||||||||||||||||||||||
| package org.example.repository; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import jakarta.persistence.EntityManager; | ||||||||||||||||||||||||||||||||||||||||||
| import org.example.entity.User; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import java.util.UUID; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public class UserRepository { | ||||||||||||||||||||||||||||||||||||||||||
| private final EntityManager em; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public UserRepository(EntityManager em) { | ||||||||||||||||||||||||||||||||||||||||||
| this.em = em; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public User getUserById(UUID id) { | ||||||||||||||||||||||||||||||||||||||||||
| return em.find(User.class, id); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public User getUserByUsername(String username) { | ||||||||||||||||||||||||||||||||||||||||||
| return em.find(User.class, username); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+21
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. Critical bug: The Apply this diff to fix: public User getUserByUsername(String username) {
- return em.find(User.class, username);
+ return em.createQuery("SELECT u FROM User u WHERE u.username = :username", User.class)
+ .setParameter("username", username)
+ .getSingleResult();
}Or handle the case where no user is found: public User getUserByUsername(String username) {
- return em.find(User.class, username);
+ try {
+ return em.createQuery("SELECT u FROM User u WHERE u.username = :username", User.class)
+ .setParameter("username", username)
+ .getSingleResult();
+ } catch (jakarta.persistence.NoResultException e) {
+ return null;
+ }
}📝 Committable suggestion
Suggested change
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public void save(User user) { | ||||||||||||||||||||||||||||||||||||||||||
| em.getTransaction().begin(); | ||||||||||||||||||||||||||||||||||||||||||
| em.persist(user); | ||||||||||||||||||||||||||||||||||||||||||
| em.getTransaction().commit(); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public void delete(User user) { | ||||||||||||||||||||||||||||||||||||||||||
| em.getTransaction().begin(); | ||||||||||||||||||||||||||||||||||||||||||
| em.remove(user); | ||||||||||||||||||||||||||||||||||||||||||
| em.getTransaction().commit(); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||||||||||||||||||||
| package org.example.service; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import org.example.entity.User; | ||||||||||||||||||||||||
| import org.example.repository.UserRepository; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import java.util.UUID; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public class UserService { | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private final UserRepository userRepository; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public UserService(UserRepository userRepository) { | ||||||||||||||||||||||||
| this.userRepository = userRepository; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public void deleteUserById(UUID id) { | ||||||||||||||||||||||||
| User user = userRepository.getUserById(id); | ||||||||||||||||||||||||
| userRepository.delete(user); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+16
to
+19
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. Add null check before deleting user. If Apply this diff to add proper null handling: public void deleteUserById(UUID id) {
User user = userRepository.getUserById(id);
+ if (user == null) {
+ throw new IllegalArgumentException("User not found with id: " + id);
+ }
userRepository.delete(user);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public User getUserById(UUID id) { | ||||||||||||||||||||||||
| return userRepository.getUserById(id); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public User getUserByUsername(String username) { | ||||||||||||||||||||||||
| return userRepository.getUserByUsername(username); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public void createUser(User user) { | ||||||||||||||||||||||||
| userRepository.save(user); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package org.example.util; | ||
|
|
||
| import jakarta.persistence.EntityManager; | ||
| import jakarta.persistence.EntityManagerFactory; | ||
| import jakarta.persistence.Persistence; | ||
|
|
||
| public class JpaUtil { | ||
|
|
||
| private static final EntityManagerFactory emf; | ||
|
|
||
| static { emf = Persistence.createEntityManagerFactory("jpa-hibernate-mysql"); | ||
| Runtime.getRuntime().addShutdownHook(new Thread(() -> | ||
| { | ||
| if (emf.isOpen()) { emf.close(); } })); | ||
| } | ||
| public static EntityManager getEntityManager() { | ||
| return emf.createEntityManager(); | ||
| } | ||
|
|
||
| public static EntityManagerFactory getEntityManagerFactory() { | ||
| return emf; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||||||
| <?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"> | ||||||||||
| <class>org.example.entity.User</class> | ||||||||||
| <properties> | ||||||||||
| <!-- Database connection settings --> | ||||||||||
| <property name="jakarta.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/invoice-db"/> | ||||||||||
|
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. Update database name to match docker-compose or use a generic name. The JDBC URL references "invoice-db", which is specific to an invoice application. For a generic template, consider using a more generic name that matches the docker-compose.yml configuration. Apply this diff: - <property name="jakarta.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/invoice-db"/>
+ <property name="jakarta.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/template-db"/>Note: This assumes you update docker-compose.yml to use "template-db" as well. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| <property name="jakarta.persistence.jdbc.user" value="root"/> | ||||||||||
| <property name="jakarta.persistence.jdbc.password" value="root"/> | ||||||||||
|
Comment on lines
+11
to
+12
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. Avoid hardcoding credentials in persistence.xml for template projects. Hardcoded credentials like "root"/"root" in the configuration file will be inherited by all projects created from this template, creating a security risk. Consider using environment variables or system properties. Apply this diff to use system properties: - <property name="jakarta.persistence.jdbc.user" value="root"/>
- <property name="jakarta.persistence.jdbc.password" value="root"/>
+ <property name="jakarta.persistence.jdbc.user" value="${DB_USER:root}"/>
+ <property name="jakarta.persistence.jdbc.password" value="${DB_PASSWORD:changeme}"/>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| <!-- Automatically export the schema --> | ||||||||||
| <property name="jakarta.persistence.schema-generation.database.action" value="drop-and-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. Change schema generation strategy from The Apply this diff: - <property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create"/>
+ <property name="jakarta.persistence.schema-generation.database.action" value="update"/>Or add a comment: - <!-- Automatically export the schema -->
+ <!-- Automatically export the schema. WARNING: drop-and-create destroys all data on restart. Change to 'update' or 'validate' for production. -->
<property name="jakarta.persistence.schema-generation.database.action" value="drop-and-create"/>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| <!-- Echo all executed SQL to console --> | ||||||||||
| <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 the redundant
MYSQL_PASSWORDenvironment variable.The
MYSQL_PASSWORDvariable is not a standard MySQL Docker environment variable for configuring the root password. OnlyMYSQL_ROOT_PASSWORD(line 7) is needed to set the root user's password.Apply this diff:
- MYSQL_PASSWORD: root MYSQL_ROOT_PASSWORD: root📝 Committable suggestion
🤖 Prompt for AI Agents