You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have code, which worked for many years. But suddenly we noticed that something was no longer working. Unfortunately, the code only runs once a year, so we don't know if other code changes caused it to stop working. Maybe it was the change from Quarkus 3.8 to 3.15.2. Unfortunately, we don't know.
We have the following Java-classes:
public class BaseEntityListener {
@PrePersist
public void prePersist(Object persistedEntity) {
if ( persistedEntity instanceof BaseEntity entity ) {
if (entity.getCreatedOn() == null) {
LocalDateTime now = LocalDateTime.now();
entity.setCreatedOn(now);
//entity.setModifiedOn(now);
}
}
}
@PostUpdate
public void postUpdate(Object persistedEntity) {
if ( persistedEntity instanceof BaseEntity entity ) {
entity.setModifiedOn(LocalDateTime.now());
System.out.println("BaseEntityListener::postUpdate");
}
}
}
@MappedSuperclass
@Data
@EntityListeners( BaseEntityListener.class )
@EqualsAndHashCode(callSuper = false)
public abstract class BaseEntity extends PanacheEntityBase implements Serializable {
@Basic
@Column( name = "CREATED_ON" )
private LocalDateTime createdOn;
@Basic
@Column( name = "MODIFIED_ON" )
private LocalDateTime modifiedOn;
}
The wertung is updated succesfully in the database. "Wert" has the value 9999 but modified_on is still null although the BaseEntityListener was running.
If I create a new Wertung, the BaseEntityListener is working as expected and writes the createdOn and modifiedOn (@PrePersist) successfully into the database.
I checked the upgrade guide from version 3.8.4 to 3.15.2 but couldn`t find anything about EntityListeners.
Maybe someone can help me out. Thanks
//EDIT
When I change @PostUpdate to @PreUpdate, the code is working and I get the localDateTime into the modifiedOn column.
Expected behavior
Write LocalDateTime into the database column modifiedOn.
Actual behavior
LocalDateTime is not written into the database column modifiedOn
How to Reproduce?
Copy the classes above and run the code :/
Output of uname -a or ver
Linux
Output of java -version
21.0.5
Quarkus version or git rev
3.15.2
Build tool (ie. output of mvnw --version or gradlew --version)
maven 3.9.9
Additional information
No response
The text was updated successfully, but these errors were encountered:
Go to application.properties and change the settings for the database connection to any database you have.
Then activate 1.Step in application properties quarkus.hibernate-orm.database.generation=drop-and-create
Run with maven command "compile quarkus:dev -Ddebug=5020"
Stop program (There is an error in the console but this is fine). The first run is only for creating the database myEntity.
open the database myEntity and input everything from import.sql under resources
Change application.properties again. Change to step 2: quarkus.hibernate-orm.database.generation=update
Otherwise quarkus would again destroy our data in the database
RUN the program. The scheduler runs and updates the entity with id 2. The update works. The field is updated but NOT the modifiedOn! BaseEntityListener @postupdate is not working correctly.
Only for testing you can change "BaseENtityListener" from @postupdate to @PreUpdate. After the change to preUpdate the update with the time into the database works but not with PostUpdate.
Describe the bug
We have code, which worked for many years. But suddenly we noticed that something was no longer working. Unfortunately, the code only runs once a year, so we don't know if other code changes caused it to stop working. Maybe it was the change from Quarkus 3.8 to 3.15.2. Unfortunately, we don't know.
We have the following Java-classes:
This is the function we call:
The wertung is updated succesfully in the database. "Wert" has the value 9999 but
modified_on
is stillnull
although theBaseEntityListener
was running.If I create a new Wertung, the BaseEntityListener is working as expected and writes the createdOn and modifiedOn (@PrePersist) successfully into the database.
I checked the upgrade guide from version 3.8.4 to 3.15.2 but couldn`t find anything about EntityListeners.
Maybe someone can help me out. Thanks
//EDIT
When I change
@PostUpdate
to@PreUpdate
, the code is working and I get the localDateTime into the modifiedOn column.Expected behavior
Write LocalDateTime into the database column modifiedOn.
Actual behavior
LocalDateTime is not written into the database column modifiedOn
How to Reproduce?
Copy the classes above and run the code :/
Output of
uname -a
orver
Linux
Output of
java -version
21.0.5
Quarkus version or git rev
3.15.2
Build tool (ie. output of
mvnw --version
orgradlew --version
)maven 3.9.9
Additional information
No response
The text was updated successfully, but these errors were encountered: