SlideShare uma empresa Scribd logo
1 de 32
Baixar para ler offline
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! 

Mais conteúdo relacionado

Destaque

Sist infgerencial4
Sist infgerencial4Sist infgerencial4
Sist infgerencial4Nauber Gois
 
Sistema infgerencial5
Sistema infgerencial5Sistema infgerencial5
Sistema infgerencial5Nauber Gois
 
Invasaocom exploits
Invasaocom exploitsInvasaocom exploits
Invasaocom exploitsNauber Gois
 
Sistemas operacionais 6
Sistemas operacionais 6Sistemas operacionais 6
Sistemas operacionais 6Nauber Gois
 
Inteligencia artifical 6
Inteligencia artifical 6Inteligencia artifical 6
Inteligencia artifical 6Nauber Gois
 
Ssit informacoesgerenciais 5
Ssit informacoesgerenciais 5Ssit informacoesgerenciais 5
Ssit informacoesgerenciais 5Nauber 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 slidesThiago Carvalho
 
Padrões de Projeto
Padrões de ProjetoPadrões de Projeto
Padrões de ProjetoNauber Gois
 
Sistemas operacionais 4
Sistemas operacionais 4Sistemas operacionais 4
Sistemas operacionais 4Nauber Gois
 
Sistemas operacionais 3
Sistemas operacionais 3Sistemas operacionais 3
Sistemas operacionais 3Nauber Gois
 
Inteligencia artificial 4
Inteligencia artificial 4Inteligencia artificial 4
Inteligencia artificial 4Nauber Gois
 
Sistemas operacionais1
Sistemas operacionais1Sistemas operacionais1
Sistemas operacionais1Nauber Gois
 
Inteligencia artificial 1
Inteligencia artificial 1Inteligencia artificial 1
Inteligencia artificial 1Nauber 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 DadosNauber Gois
 
Testes nao funcionais 1
Testes nao funcionais 1Testes nao funcionais 1
Testes nao funcionais 1Nauber Gois
 
Sistemas infgerencial3
Sistemas infgerencial3Sistemas infgerencial3
Sistemas infgerencial3Nauber Gois
 
Seguranca informacao 1
Seguranca informacao 1Seguranca informacao 1
Seguranca informacao 1Nauber Gois
 
Inteligencia artifical 7
Inteligencia artifical 7Inteligencia artifical 7
Inteligencia artifical 7Nauber Gois
 

Destaque (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
 

Semelhante a 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-WAREFermin 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 EclipsePeter 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 ComponentsHassan Abid
 
BP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesBP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesAlfresco 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 TornadoGavin Roy
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsLewis Ardern
 
Ambari Views - Overview
Ambari Views - OverviewAmbari Views - Overview
Ambari Views - OverviewHortonworks
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWAREFIWARE
 
APPlause - DemoCamp Munich
APPlause - DemoCamp MunichAPPlause - DemoCamp Munich
APPlause - DemoCamp MunichPeter 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 enversRomain Linsolas
 
Resthub framework presentation
Resthub framework presentationResthub framework presentation
Resthub framework presentationSé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 ScaleIstanbul Tech Talks
 
JSONpedia - Facilitating consumption of MediaWiki content
JSONpedia - Facilitating consumption of MediaWiki contentJSONpedia - Facilitating consumption of MediaWiki content
JSONpedia - Facilitating consumption of MediaWiki contentMichele Mostarda
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web DevelopmentRobert 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 StitchMongoDB
 
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 TechnologyMałgorzata Borzęcka
 

Semelhante a 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
 

Mais de Diogo Souza

GraalVM: Harder, Better, Faster, Stronger
GraalVM: Harder, Better, Faster, StrongerGraalVM: Harder, Better, Faster, Stronger
GraalVM: Harder, Better, Faster, StrongerDiogo 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 tiDiogo 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 guiceDiogo Souza
 

Mais de 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
 

Último

Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfROWELL MARQUINA
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Laying the Data Foundations for Artificial Intelligence!
Laying the Data Foundations for Artificial Intelligence!Laying the Data Foundations for Artificial Intelligence!
Laying the Data Foundations for Artificial Intelligence!Memoori
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Deliver Latency Free Customer Experience
Deliver Latency Free Customer ExperienceDeliver Latency Free Customer Experience
Deliver Latency Free Customer ExperienceOpsTree solutions
 
WomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneWomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneUiPathCommunity
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
Why Agile? - A handbook behind Agile Evolution
Why Agile? - A handbook behind Agile EvolutionWhy Agile? - A handbook behind Agile Evolution
Why Agile? - A handbook behind Agile EvolutionDEEPRAJ PATHAK
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Which standard is best for your content?
Which standard is best for your content?Which standard is best for your content?
Which standard is best for your content?Rustici Software
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 

Último (20)

Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdf
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Laying the Data Foundations for Artificial Intelligence!
Laying the Data Foundations for Artificial Intelligence!Laying the Data Foundations for Artificial Intelligence!
Laying the Data Foundations for Artificial Intelligence!
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Deliver Latency Free Customer Experience
Deliver Latency Free Customer ExperienceDeliver Latency Free Customer Experience
Deliver Latency Free Customer Experience
 
WomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneWomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyone
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
Why Agile? - A handbook behind Agile Evolution
Why Agile? - A handbook behind Agile EvolutionWhy Agile? - A handbook behind Agile Evolution
Why Agile? - A handbook behind Agile Evolution
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Which standard is best for your content?
Which standard is best for your content?Which standard is best for your content?
Which standard is best for your content?
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 

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.