]
Gail Badner commented on HHH-5722:
----------------------------------
If you provide a test case that reproduces your issue, I'll re-open.
Please see details for providing the test case at
Method annotated with @PreUpdade is not called
----------------------------------------------
Key: HHH-5722
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5722
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.6.0
Environment: Java 1.6.0_21, Windows and Linux
Reporter: Oleksandr Alesinskyy
Assignee: Gail Badner
I have a class with methods annotated @PostLoad, @PrePersist, and @PreUpdate as below:
{code:title=Snippet}
@Transient
private B2BCustomerKeyPo b2BCustomerKey;
@Embedded
@AttributeOverrides( { @AttributeOverride(name = "username", column =
@Column(name = "APPLICATION_NAME")),
@AttributeOverride(name = "b2BCustomerName", column = @Column(name
= "B2BCUSTOMER_NAME")) })
private UserKeyPo applicationKey;
...
@SuppressWarnings("unused")
@PostLoad
private void postLoad() {
if (applicationKey != null) {
if (applicationKey.getB2BCustomerName() != null) {
b2BCustomerKey = new
B2BCustomerKeyPo(applicationKey.getB2BCustomerName());
}
if (applicationKey.getUsername() == null) applicationKey = null;
}
}
@SuppressWarnings("unused")
@PrePersist
private void prePersist() {
if (b2BCustomerKey != null) {
if (applicationKey != null) {
if (!b2BCustomerKey.equals(new
B2BCustomerKeyPo(applicationKey.getB2BCustomerName()))) {
final String msg =
String
.format(
"B2B customer [%s] of the product does
not match the Application of the product [%s/%s]",
b2BCustomerKey.getName(),
applicationKey.getB2BCustomerName(),
applicationKey.getUsername());
throw new IllegalStateException(msg);
}
} else {
applicationKey = new UserKeyPo(b2BCustomerKey.getName(), null);
}
}
}
@SuppressWarnings("unused")
@PreUpdate
private void preUpdate() {
throw new RuntimeException("§TEST§");
}
{code}
prePersist and postLoad methods work as expected but preUpdate method is not called at
all - while updated fields are dutifully written into DB (they never would if preUopdate
will be called).
The code manipulating the object is as below:
{code:title=Snippet2}
ProductPo productPoOld =
readProductPo(input.getProduct().getProductKey().getExternalProductKey());
...
B2BCustomerKey b2bCustomerKey = productNew.getB2BCustomerKey();
productPoOld.setB2BCustomerKey(mappingHelper.mapObject(productNew.getB2BCustomerKey(),
B2BCustomerKeyPo.class));
LOG.debug(productPoOld.getB2BCustomerKey());
// @PreUpdate method is not called regardless if flush is present below or not
productDao.flush();
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: