SlideShare une entreprise Scribd logo
1  sur  32
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! 

Contenu connexe

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus 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
 

Plus 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
 

Dernier

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Dernier (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

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.