use of javax.persistence.PrePersist in project Protocol-Adapter-IEC61850 by OSGP.
the class Device method prePersist.
/**
* Method for actions to be taken before inserting.
*/
@PrePersist
private void prePersist() {
final Date now = new Date();
this.creationTime = now;
this.modificationTime = now;
}
use of javax.persistence.PrePersist 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.PrePersist in project deltaspike by apache.
the class AuditEntityListener method persist.
@PrePersist
public void persist(Object entity) {
BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
Set<Bean<?>> beans = beanManager.getBeans(PrePersistAuditListener.class);
for (Bean<?> bean : beans) {
PrePersistAuditListener result = (PrePersistAuditListener) beanManager.getReference(bean, PrePersistAuditListener.class, beanManager.createCreationalContext(bean));
result.prePersist(entity);
}
}
use of javax.persistence.PrePersist 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.PrePersist in project simplejpa by appoxy.
the class SomeEntityListener method prePersist.
@PrePersist
public void prePersist(Object object) {
System.out.println("prePersist");
if (object instanceof Timestamped) {
System.out.println("Setting timestamps.");
Timestamped timestamped = (Timestamped) object;
Date now = new Date();
timestamped.setCreated(now);
timestamped.setUpdated(now);
}
}
Aggregations