use of javax.persistence.PreUpdate in project simplejpa by appoxy.
the class SomeEntityListener method preUpdate.
@PreUpdate
public void preUpdate(Object object) {
System.out.println("preUpdate.");
if (object instanceof Timestamped) {
System.out.println("Setting timestamps.");
Timestamped timestamped = (Timestamped) object;
timestamped.setUpdated(new Date());
}
}
use of javax.persistence.PreUpdate in project wildfly by wildfly.
the class LastUpdateListener method setLastUpdate.
@PreUpdate
@PrePersist
public void setLastUpdate(Cat o) {
o.setLastUpdate(new Date());
o.setManualVersion(o.getManualVersion() + 1);
}
use of javax.persistence.PreUpdate in project wildfly by wildfly.
the class MyListener method onEntityCallback.
@PrePersist
@PreUpdate
public void onEntityCallback(Object entity) {
try {
invocationCount++;
InitialContext jndiContext = new InitialContext();
EJBContext ctx = (EJBContext) jndiContext.lookup("java:comp/EJBContext");
//System.out.println(ctx.getCallerPrincipal().getName() + ", entity=" + entity);
} catch (NamingException e) {
throw new RuntimeException("initial context error", e);
}
}
use of javax.persistence.PreUpdate in project simplejpa by appoxy.
the class TimestampEntityListener method preUpdate.
@PreUpdate
public void preUpdate(Object object) {
if (object instanceof Timestamped) {
Timestamped timestamped = (Timestamped) object;
timestamped.setUpdated(new Date());
}
}
use of javax.persistence.PreUpdate in project hibernate-orm by hibernate.
the class LastUpdateListener method setLastUpdate.
@PreUpdate
@PrePersist
public void setLastUpdate(Cat o) {
o.setLastUpdate(new Date());
o.setManualVersion(o.getManualVersion() + 1);
}
Aggregations