SlideShare a Scribd company logo
Envers + Seam + JBoss: Why
to use?
Diogo Souza
Envers + Seam + JBoss:
Why to use?
Better...
The handshake
Diogo Souza
Systems Analyst at Indra Company
http://3adiX.com.br
http://diogosouza.com.br
@diogo_souza_c
Ah, the Envers!
Once upon a time, in 2009…
What they say about…
“The Envers project aims to enable
easy auditing/versioning of persistent
classes […]”
Ref: http://www.jboss.org/envers
What they say about…
“[…] All that you have to do is
annotate your persistent class or
some of its properties, that you want
to audit, with @Audited. […]”
Ref: http://www.jboss.org/envers
What they say about…
“[…] For each audited entity, a table
will be created, which will hold the
history of changes made to the
entity. […]”
Ref: http://www.jboss.org/envers
And the best part…
“[…] You can then retrieve and query
historical data without much effort.”
Ref: http://www.jboss.org/envers
http://www.deviantart.com
Some features:
 Auditing of all mappings defined by
the JPA specification
 Auditing of some Hibernate
mappings, which extend JPA
 Logging data for each revision using
a "revision entity"
 Querying historical data
Ref: http://www.jboss.org/envers
http://www.deviantart.com
Basically
Each transaction...
...One revision
INSERT
UPDATE
DELETE
Where to use?
Wherever you have Hibernate!
 Standalone
 JBoss AS
 Spring
And how do we use in the past?
<property name="hibernate.ejb.event.post-insert"
value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernat
e.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.post-update"
value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hiberna
te.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.post-delete"
value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernat
e.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.pre-collection-update"
value="org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.pre-collection-remove"
value="org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.post-collection-recreate"
value="org.hibernate.envers.event.AuditEventListener" />
In persistence.xml or hibernate.cfg.xml
And how to use?
<!-- Add on classpath | Maven -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>4.x.Final</version>
</dependency>
Requirements:
Hibernate 3+
Hibernate annotations
Simple sample
@Entity
public class Adress {
@Id
@GeneratedValue
private int id;
@Audited
private String streetName;
@Audited
private Long zipCode;
@Audited
@ManyToOne
private State state;
}
The whole entity
@Audited
public class Adress {
@Id
@GeneratedValue
private int id;
private String streetName;
private Long zipCode;
@ManyToOne
private State state;
}
@Audited // Here too!
public class State {
@Id
@GeneratedValue
private int id;
private String stateName;
private Long population;
}
… without a field
@Audited
public class Adress {
@Id
@GeneratedValue
private int id;
@NotAudited
private String streetName;
private Long zipCode;
@ManyToOne
private State state;
}
Changing the entity table
name
@Audited
@AuditTable(“TB_ADRESS_AUDIT”)
public class Adress {
@Id
@GeneratedValue
private int id;
@NotAudited
private String streetName;
private Long zipCode;
@ManyToOne
private State state;
}
The database
0 ADD
1 MOD
3 DEL
The revision
date!
Querying for entities of a
class at a given revision
AuditQuery query =
getAuditReader().createQuery()
.forEntitiesAtRevision(MyEntity.class,
revisionNumber);
Querying for revisions, at
which entities of a given class
changed
AuditQuery query =
getAuditReader().createQuery()
.forRevisionsOfEntity(MyEntity.class,
false, true);
Querying for revisions
between revision dates
AuditReader auditReader =
AuditReaderFactory.get(entityManager);
AuditQuery query = auditReader.createQuery()
.forRevisionsOfEntity(Punishment.class, false, true)
.add(AuditEntity.revisionProperty("timestamp")
.gt(timeStamp).lt(otherTimeStamp)
.add(AuditEntity.revisionType().eq(RevisionType.ADD));
List<Object[]> revisions = query.getResultList();
Configuration Properties
// Prefixes and suffixes
org.hibernate.envers.audit_table_prefix
org.hibernate.envers.audit_table_suffix
// Revision number and revision type fields
org.hibernate.envers.revision_field_name
org.hibernate.envers.revision_type_field_name
// Default schema used
org.hibernate.envers.default_schema
Demo Time!
I am not responsible for
any increases in the
number of Brazilian
punishments...
The guy!
Adam Warski
Ref: http://www.warski.org/blog/about/
http://warski.org
Good things!
 Easy!
 Data as always!
 Database schema
doesn’t change
 Minimal code changes
 Integration with
Hibernate/Red Hat
related
Not so good things!
 Dependency of
Hibernate.
 Not compatible with
Hibernate-XML-Age.
 Extra table for each
table.
Story Time!
References/Links
 www.jboss.org/envers
 http://docs.jboss.org/envers/docs/
 http://www.warski.org/blog/
Thanks! 

More Related Content

Viewers also liked

Sist infgerencial4
Sist infgerencial4Sist infgerencial4
Sist infgerencial4
Nauber Gois
 
Beefataque
BeefataqueBeefataque
Beefataque
Nauber Gois
 
Sistema infgerencial5
Sistema infgerencial5Sistema infgerencial5
Sistema infgerencial5
Nauber Gois
 
Invasaocom exploits
Invasaocom exploitsInvasaocom exploits
Invasaocom exploits
Nauber Gois
 
Sistemas operacionais 6
Sistemas operacionais 6Sistemas operacionais 6
Sistemas operacionais 6
Nauber Gois
 
Inteligencia artifical 6
Inteligencia artifical 6Inteligencia artifical 6
Inteligencia artifical 6
Nauber Gois
 
Ssit informacoesgerenciais 5
Ssit informacoesgerenciais 5Ssit informacoesgerenciais 5
Ssit informacoesgerenciais 5
Nauber Gois
 
Processo de automação de artefatos de requisito slides
Processo de automação de artefatos de requisito   slidesProcesso de automação de artefatos de requisito   slides
Processo de automação de artefatos de requisito slides
Thiago Carvalho
 
Padrões de Projeto
Padrões de ProjetoPadrões de Projeto
Padrões de Projeto
Nauber Gois
 
Sistemas operacionais 4
Sistemas operacionais 4Sistemas operacionais 4
Sistemas operacionais 4
Nauber Gois
 
Sistemas operacionais 3
Sistemas operacionais 3Sistemas operacionais 3
Sistemas operacionais 3
Nauber Gois
 
Inteligencia artificial 4
Inteligencia artificial 4Inteligencia artificial 4
Inteligencia artificial 4
Nauber Gois
 
Sistemas operacionais1
Sistemas operacionais1Sistemas operacionais1
Sistemas operacionais1
Nauber Gois
 
Inteligencia artificial 1
Inteligencia artificial 1Inteligencia artificial 1
Inteligencia artificial 1
Nauber Gois
 
Data science
Data scienceData science
Data science
Nauber Gois
 
Introdução a Ciência de Dados
Introdução a Ciência de DadosIntrodução a Ciência de Dados
Introdução a Ciência de Dados
Nauber Gois
 
Testes nao funcionais 1
Testes nao funcionais 1Testes nao funcionais 1
Testes nao funcionais 1
Nauber Gois
 
Sistemas infgerencial3
Sistemas infgerencial3Sistemas infgerencial3
Sistemas infgerencial3
Nauber Gois
 
Seguranca informacao 1
Seguranca informacao 1Seguranca informacao 1
Seguranca informacao 1
Nauber Gois
 
Inteligencia artifical 7
Inteligencia artifical 7Inteligencia artifical 7
Inteligencia artifical 7
Nauber Gois
 

Viewers also liked (20)

Sist infgerencial4
Sist infgerencial4Sist infgerencial4
Sist infgerencial4
 
Beefataque
BeefataqueBeefataque
Beefataque
 
Sistema infgerencial5
Sistema infgerencial5Sistema infgerencial5
Sistema infgerencial5
 
Invasaocom exploits
Invasaocom exploitsInvasaocom exploits
Invasaocom exploits
 
Sistemas operacionais 6
Sistemas operacionais 6Sistemas operacionais 6
Sistemas operacionais 6
 
Inteligencia artifical 6
Inteligencia artifical 6Inteligencia artifical 6
Inteligencia artifical 6
 
Ssit informacoesgerenciais 5
Ssit informacoesgerenciais 5Ssit informacoesgerenciais 5
Ssit informacoesgerenciais 5
 
Processo de automação de artefatos de requisito slides
Processo de automação de artefatos de requisito   slidesProcesso de automação de artefatos de requisito   slides
Processo de automação de artefatos de requisito slides
 
Padrões de Projeto
Padrões de ProjetoPadrões de Projeto
Padrões de Projeto
 
Sistemas operacionais 4
Sistemas operacionais 4Sistemas operacionais 4
Sistemas operacionais 4
 
Sistemas operacionais 3
Sistemas operacionais 3Sistemas operacionais 3
Sistemas operacionais 3
 
Inteligencia artificial 4
Inteligencia artificial 4Inteligencia artificial 4
Inteligencia artificial 4
 
Sistemas operacionais1
Sistemas operacionais1Sistemas operacionais1
Sistemas operacionais1
 
Inteligencia artificial 1
Inteligencia artificial 1Inteligencia artificial 1
Inteligencia artificial 1
 
Data science
Data scienceData science
Data science
 
Introdução a Ciência de Dados
Introdução a Ciência de DadosIntrodução a Ciência de Dados
Introdução a Ciência de Dados
 
Testes nao funcionais 1
Testes nao funcionais 1Testes nao funcionais 1
Testes nao funcionais 1
 
Sistemas infgerencial3
Sistemas infgerencial3Sistemas infgerencial3
Sistemas infgerencial3
 
Seguranca informacao 1
Seguranca informacao 1Seguranca informacao 1
Seguranca informacao 1
 
Inteligencia artifical 7
Inteligencia artifical 7Inteligencia artifical 7
Inteligencia artifical 7
 

Similar to Envers + Seam + JBoss: Why to use?

Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
Fermin Galan
 
Cross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipseCross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with Eclipse
Peter Friese
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
Hassan Abid
 
BP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesBP-6 Repository Customization Best Practices
BP-6 Repository Customization Best Practices
Alfresco Software
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
James Titcumb
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
Gavin Roy
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript Applications
Lewis Ardern
 
Ambari Views - Overview
Ambari Views - OverviewAmbari Views - Overview
Ambari Views - Overview
Hortonworks
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
FIWARE
 
APPlause - DemoCamp Munich
APPlause - DemoCamp MunichAPPlause - DemoCamp Munich
APPlause - DemoCamp Munich
Peter Friese
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Red Hat Developers
 
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
James Titcumb
 
Devoxx 2012 hibernate envers
Devoxx 2012   hibernate enversDevoxx 2012   hibernate envers
Devoxx 2012 hibernate envers
Romain Linsolas
 
Resthub framework presentation
Resthub framework presentationResthub framework presentation
Resthub framework presentation
Sébastien Deleuze
 
ITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
ITT 2015 - Simon Stewart - Building Android Apps at Speed and ScaleITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
ITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
Istanbul Tech Talks
 
JSONpedia - Facilitating consumption of MediaWiki content
JSONpedia - Facilitating consumption of MediaWiki contentJSONpedia - Facilitating consumption of MediaWiki content
JSONpedia - Facilitating consumption of MediaWiki content
Michele Mostarda
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web Development
Robert J. Stein
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
James Titcumb
 
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB.local Sydney: Evolving your Data Access with MongoDB StitchMongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB
 
ASP.NET MVC Workshop for Women in Technology
ASP.NET MVC Workshop for Women in TechnologyASP.NET MVC Workshop for Women in Technology
ASP.NET MVC Workshop for Women in Technology
Małgorzata Borzęcka
 

Similar to Envers + Seam + JBoss: Why to use? (20)

Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
 
Cross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipseCross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with Eclipse
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
BP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesBP-6 Repository Customization Best Practices
BP-6 Repository Customization Best Practices
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript Applications
 
Ambari Views - Overview
Ambari Views - OverviewAmbari Views - Overview
Ambari Views - Overview
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
 
APPlause - DemoCamp Munich
APPlause - DemoCamp MunichAPPlause - DemoCamp Munich
APPlause - DemoCamp Munich
 
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
Boost Development With Java EE7 On EAP7 (Demitris Andreadis)
 
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
 
Devoxx 2012 hibernate envers
Devoxx 2012   hibernate enversDevoxx 2012   hibernate envers
Devoxx 2012 hibernate envers
 
Resthub framework presentation
Resthub framework presentationResthub framework presentation
Resthub framework presentation
 
ITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
ITT 2015 - Simon Stewart - Building Android Apps at Speed and ScaleITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
ITT 2015 - Simon Stewart - Building Android Apps at Speed and Scale
 
JSONpedia - Facilitating consumption of MediaWiki content
JSONpedia - Facilitating consumption of MediaWiki contentJSONpedia - Facilitating consumption of MediaWiki content
JSONpedia - Facilitating consumption of MediaWiki content
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web Development
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
 
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB.local Sydney: Evolving your Data Access with MongoDB StitchMongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
MongoDB.local Sydney: Evolving your Data Access with MongoDB Stitch
 
ASP.NET MVC Workshop for Women in Technology
ASP.NET MVC Workshop for Women in TechnologyASP.NET MVC Workshop for Women in Technology
ASP.NET MVC Workshop for Women in Technology
 

More from Diogo Souza

GraalVM: Harder, Better, Faster, Stronger
GraalVM: Harder, Better, Faster, StrongerGraalVM: Harder, Better, Faster, Stronger
GraalVM: Harder, Better, Faster, Stronger
Diogo Souza
 
Batch, Spring, Performance e outras coisas mais...
Batch, Spring, Performance e outras coisas mais...Batch, Spring, Performance e outras coisas mais...
Batch, Spring, Performance e outras coisas mais...
Diogo Souza
 
Desenvolvimento Web: Por que Java?
Desenvolvimento Web: Por que Java?Desenvolvimento Web: Por que Java?
Desenvolvimento Web: Por que Java?
Diogo Souza
 
Android: Por que usar? Como desenvolver?
Android: Por que usar? Como desenvolver?Android: Por que usar? Como desenvolver?
Android: Por que usar? Como desenvolver?
Diogo Souza
 
Java, android e o mercado de ti
Java, android e o mercado de tiJava, android e o mercado de ti
Java, android e o mercado de ti
Diogo Souza
 
Simples pelo simples google android com robo guice
Simples pelo simples   google android com robo guiceSimples pelo simples   google android com robo guice
Simples pelo simples google android com robo guice
Diogo Souza
 

More from Diogo Souza (6)

GraalVM: Harder, Better, Faster, Stronger
GraalVM: Harder, Better, Faster, StrongerGraalVM: Harder, Better, Faster, Stronger
GraalVM: Harder, Better, Faster, Stronger
 
Batch, Spring, Performance e outras coisas mais...
Batch, Spring, Performance e outras coisas mais...Batch, Spring, Performance e outras coisas mais...
Batch, Spring, Performance e outras coisas mais...
 
Desenvolvimento Web: Por que Java?
Desenvolvimento Web: Por que Java?Desenvolvimento Web: Por que Java?
Desenvolvimento Web: Por que Java?
 
Android: Por que usar? Como desenvolver?
Android: Por que usar? Como desenvolver?Android: Por que usar? Como desenvolver?
Android: Por que usar? Como desenvolver?
 
Java, android e o mercado de ti
Java, android e o mercado de tiJava, android e o mercado de ti
Java, android e o mercado de ti
 
Simples pelo simples google android com robo guice
Simples pelo simples   google android com robo guiceSimples pelo simples   google android com robo guice
Simples pelo simples google android com robo guice
 

Recently uploaded

[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
Edge AI and Vision Alliance
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
Antonios Katsarakis
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 

Recently uploaded (20)

[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
“How Axelera AI Uses Digital Compute-in-memory to Deliver Fast and Energy-eff...
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Dandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity serverDandelion Hashtable: beyond billion requests per second on a commodity server
Dandelion Hashtable: beyond billion requests per second on a commodity server
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 

Envers + Seam + JBoss: Why to use?

  • 1.
  • 2. Envers + Seam + JBoss: Why to use? Diogo Souza
  • 3. Envers + Seam + JBoss: Why to use? Better...
  • 5. Diogo Souza Systems Analyst at Indra Company http://3adiX.com.br http://diogosouza.com.br @diogo_souza_c
  • 6. Ah, the Envers! Once upon a time, in 2009…
  • 7. What they say about… “The Envers project aims to enable easy auditing/versioning of persistent classes […]” Ref: http://www.jboss.org/envers
  • 8. What they say about… “[…] All that you have to do is annotate your persistent class or some of its properties, that you want to audit, with @Audited. […]” Ref: http://www.jboss.org/envers
  • 9. What they say about… “[…] For each audited entity, a table will be created, which will hold the history of changes made to the entity. […]” Ref: http://www.jboss.org/envers
  • 10. And the best part… “[…] You can then retrieve and query historical data without much effort.” Ref: http://www.jboss.org/envers http://www.deviantart.com
  • 11. Some features:  Auditing of all mappings defined by the JPA specification  Auditing of some Hibernate mappings, which extend JPA  Logging data for each revision using a "revision entity"  Querying historical data Ref: http://www.jboss.org/envers http://www.deviantart.com
  • 13. Where to use? Wherever you have Hibernate!  Standalone  JBoss AS  Spring
  • 14. And how do we use in the past? <property name="hibernate.ejb.event.post-insert" value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernat e.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.post-update" value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hiberna te.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.post-delete" value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernat e.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.pre-collection-update" value="org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.pre-collection-remove" value="org.hibernate.envers.event.AuditEventListener" /> <property name="hibernate.ejb.event.post-collection-recreate" value="org.hibernate.envers.event.AuditEventListener" /> In persistence.xml or hibernate.cfg.xml
  • 15. And how to use? <!-- Add on classpath | Maven --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-envers</artifactId> <version>4.x.Final</version> </dependency> Requirements: Hibernate 3+ Hibernate annotations
  • 16. Simple sample @Entity public class Adress { @Id @GeneratedValue private int id; @Audited private String streetName; @Audited private Long zipCode; @Audited @ManyToOne private State state; }
  • 17. The whole entity @Audited public class Adress { @Id @GeneratedValue private int id; private String streetName; private Long zipCode; @ManyToOne private State state; } @Audited // Here too! public class State { @Id @GeneratedValue private int id; private String stateName; private Long population; }
  • 18. … without a field @Audited public class Adress { @Id @GeneratedValue private int id; @NotAudited private String streetName; private Long zipCode; @ManyToOne private State state; }
  • 19. Changing the entity table name @Audited @AuditTable(“TB_ADRESS_AUDIT”) public class Adress { @Id @GeneratedValue private int id; @NotAudited private String streetName; private Long zipCode; @ManyToOne private State state; }
  • 20. The database 0 ADD 1 MOD 3 DEL The revision date!
  • 21. Querying for entities of a class at a given revision AuditQuery query = getAuditReader().createQuery() .forEntitiesAtRevision(MyEntity.class, revisionNumber);
  • 22. Querying for revisions, at which entities of a given class changed AuditQuery query = getAuditReader().createQuery() .forRevisionsOfEntity(MyEntity.class, false, true);
  • 23. Querying for revisions between revision dates AuditReader auditReader = AuditReaderFactory.get(entityManager); AuditQuery query = auditReader.createQuery() .forRevisionsOfEntity(Punishment.class, false, true) .add(AuditEntity.revisionProperty("timestamp") .gt(timeStamp).lt(otherTimeStamp) .add(AuditEntity.revisionType().eq(RevisionType.ADD)); List<Object[]> revisions = query.getResultList();
  • 24. Configuration Properties // Prefixes and suffixes org.hibernate.envers.audit_table_prefix org.hibernate.envers.audit_table_suffix // Revision number and revision type fields org.hibernate.envers.revision_field_name org.hibernate.envers.revision_type_field_name // Default schema used org.hibernate.envers.default_schema
  • 26. I am not responsible for any increases in the number of Brazilian punishments...
  • 27. The guy! Adam Warski Ref: http://www.warski.org/blog/about/ http://warski.org
  • 28. Good things!  Easy!  Data as always!  Database schema doesn’t change  Minimal code changes  Integration with Hibernate/Red Hat related
  • 29. Not so good things!  Dependency of Hibernate.  Not compatible with Hibernate-XML-Age.  Extra table for each table.