SlideShare a Scribd company logo
1 of 15
Download to read offline
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
BLG 411E – Software Engineering 
Recitation Session 4 
Application Logging and Object-Relational Mapping 
Atakan Aral, Bilge Süheyla Akkoca 
02.12.2014
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Outline 
1 Logging 
Log4j 
2 ORM 
Hibernate 
3 References
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Application Logging 
Introduction 
Definition 
Recording the events which happen during a software 
execution. 
Logging allows to: 
audit important items, 
analyze application use, 
trace errors. 
Performance is the most important consideration.
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Application Logging 
Logging Levels 
OFF No logging 
FATAL Only errors that cause the application to abort 
ERROR Critical errors that prevent the use case from 
continuing 
WARN Other errors and exceptions where processes 
may still continue, i.e. “Current data 
unavailable, using cached values” 
INFO Life cycle events, completion of use cases, i.e. 
“[Who] booked ticket from [Where] to [Where]” 
DEBUG All other (sub) events 
TRACE All method invocations with parameter and 
return values
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Application Logging 
Tips 
Apply logging levels appropriately 
Avoid side effects (no impact on the application’s 
behavior) 
Log for easy reading and easy parsing 
Include both data and description, no magic numbers 
or characters (i.e. &&&) 
Use a logging pattern (i.e. %d{HH:mm:ss.SSS} 
%-5level [%thread][%logger{0}] %m%n) 
Maximize logging for external systems 
Maximize logging when in trouble, not otherwise 
Avoid excessive string concatenation, use parametrized 
logging methods 
Do not log sensitive information
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Log4j 
Introduction 
Definition 
A Java-based logging utility which provides performance 
improvements and advanced filtering. 
import org . apache . logging . l o g 4 j . LogManager ; 
import org . apache . logging . l o g 4 j . Logger ; 
public class HelloWorld { 
pr ivate s t a t i c f i n a l Logger l 
= LogManager . getLogger ( " HelloWorld " ) ; 
public s t a t i c void main ( St r i n g [ ] args ) { 
l . i n f o ( " Hello , World ! " ) ; 
l . e r r o r ( " Mission f a i l e d ! " ) ; 
} 
}
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Object-Relational Mapping 
Definitions 
Persistence Application’s data to outlive the 
applications process, state of objects 
to live beyond the scope of the JVM so 
that the same state is available later 
DMSs Although ODBMSs are emerging, 
RDBMSs are still the most popular 
ones. 
Paradigm mismatch Object models (i.e. Java) and 
relational models (i.e. SQL) do not 
work very well together. See the next 
slide for the details. 
ORM A programming technique for 
converting data between the two 
incompatible type systems
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Object-Relational Mapping 
Object-relational impedance mismatch 
RDBMSs represent data in a tabular format where 
object-oriented languages represent it as an inter-connected 
graph of objects. Mismatch problems: 
Granularity Object model usually has more classes 
than the number of corresponding tables 
in the database. 
Subtypes Inheritance in OOP does not exist in 
RDBMSs. 
Identity OOP supports identity (a == b) and 
equality (a:equals(b)) while RDBMSs only 
support identity (the primary key). 
Association References vs. foreign keys 
Navigation In OOP, navigation is from one association 
to another, walking the object network. 
That is inefficient in RDBMSs, so JOINs 
are used.
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Hibernate 
Introduction 
Definition 
Hibernate is an ORM library for Java that solves object-relational 
impedance mismatch problems by replacing direct 
persistence-related DB access with high-level object 
handling functions. 
Allows developer to concentrate on Java code instead 
of complex SQL statements. 
Reduces the lines of code, makes the system more 
understandable and easier to maintain. 
Abstracts the application away from the underlying SQL 
database and dialect, fosters portability.
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Hibernate 
Hibernate mapping file 
Class–Table 
Property–Id 
Property–Column 
Types and column names are optional. 
<hibernatemapping 
class name= Product  tab l e =PRODUCTS 
 i d name= product Id  column= pid   
generator class= assigned  /  
 / i d  
proper t y name=proName column=pname /  
proper t y name= p r i c e  /  
proper t y name= date  type= timestamp  
column= creat ion_date  /  
 / class 
 / hibernatemapping
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Hibernate 
Hibernate configuration file 
JDBC connection information (connection.driver_class, 
connection.username, connection.password, 
connection.url) 
Number of connections (connection.pool_size) 
SQL variant (dialect) 
DB schema generation (hbm2ddl.auto) 
Mapping persistent classes (mapping)
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Hibernate 
Hibernate configuration file 
hibernatec o n f i g u r a t i o n  
sessionf a c t o r y  
proper t y name= connect ion . d r i v e r _ c l a s s  
oracle . jdbc . d r i v e r . OracleDr iver 
 / proper t y 
proper t y name= connect ion . u r l  
jdbc:oracle: thin:@www . java4s . com:1521:XE 
 / proper t y 
proper t y name= connect ion . user user / proper t y 
proper t y name= connect ion . password  
password 
 / proper t y 
proper t y name= show_sql t rue  / proper t y 
proper t y name= d i a l e c t  
org . hibernate . d i a l e c t . Orac leDialec t 
 / proper t y 
proper t y name= hbm2ddl . auto update / proper t y 
mapping resource= product .hbm. xml  /  
 / sessionf a c t o r y  
 / hibernatec o n f i g u r a t i o n
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Hibernate 
Sample program code 
import org . hibernate .  ; 
import org . hibernate . cfg .  ; 
public class Cl ientForSave { 
public s t a t i c void main ( St r i n g [ ] args ) { 
Conf igurat ion cfg = new Conf igurat ion ( ) ; 
cfg . conf igure (  hibernate . cfg . xml  ) ; 
SessionFactory f a c t o r y = cfg . bui ldSessionFactory ( ) ; 
Session session = f a c t o r y . openSession ( ) ; 
Product p = new Product ( ) ; 
p . setProduct Id ( 1 0 1 ) ; 
p . setProName (  iPhone  ) ; 
p . setPr i ce (25000) ; 
p . setDate (new Date ( ) ) ; 
session . beginTransact ion ( ) ; 
session . save ( p ) ; 
session . getTransact ion ( ) . commit ( ) ; 
session . close ( ) ; 
f a c t o r y . close ( ) ; 
} 
}
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
Hibernate 
Sample program code 
session = sessionFactory . openSession ( ) ; 
session . beginTransact ion ( ) ; 
L i s t r e s u l t = session . createQuery (  from PRODUCTS ) . l i s t ( ) ; 
for ( Product p : ( L i s t Product ) r e s u l t ) { 
System. out . p r i n t l n (  Product (  
+ p . setProduct Id ( ) +  ) :  + p . setProName ( ) ) ; 
} 
session . getTransact ion ( ) . commit ( ) ; 
session . close ( ) ;
BLG 411E 
Software 
Engineering 
Recitation 4 
Logging 
Log4j 
ORM 
Hibernate 
References 
References and Further Reading 
http://www.javacodegeeks.com/2011/01/ 
10-tips-proper-application-logging.html 
http: 
//blogg.kantega.no/logging-in-java-with-users-in-mind/ 
http://logging.apache.org/log4j/2.x/ 
http://www.agiledata.org/essays/impedanceMismatch.html 
http://hibernate.org/orm/ 
http://www.java4s.com/hibernate/ 
hibernate-hello-world-program-saving-an-objcet/

More Related Content

What's hot

Delving (Smalltalk) Source Code
Delving (Smalltalk) Source CodeDelving (Smalltalk) Source Code
Delving (Smalltalk) Source CodeESUG
 
Hypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data RESTHypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data RESTSofiia Vynnytska
 
RDKit UGM 2016: Higher Quality Chemical Depictions
RDKit UGM 2016: Higher Quality Chemical DepictionsRDKit UGM 2016: Higher Quality Chemical Depictions
RDKit UGM 2016: Higher Quality Chemical DepictionsNextMove Software
 
Gc algorithm inside_dot_net
Gc algorithm inside_dot_netGc algorithm inside_dot_net
Gc algorithm inside_dot_netWei Sun
 
WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaKatrien Verbert
 
Finding Logic Bugs in Database Management Systems
Finding Logic Bugs in Database Management SystemsFinding Logic Bugs in Database Management Systems
Finding Logic Bugs in Database Management SystemsPingCAP
 

What's hot (8)

Delving (Smalltalk) Source Code
Delving (Smalltalk) Source CodeDelving (Smalltalk) Source Code
Delving (Smalltalk) Source Code
 
Hypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data RESTHypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data REST
 
RDKit UGM 2016: Higher Quality Chemical Depictions
RDKit UGM 2016: Higher Quality Chemical DepictionsRDKit UGM 2016: Higher Quality Chemical Depictions
RDKit UGM 2016: Higher Quality Chemical Depictions
 
Gc algorithm inside_dot_net
Gc algorithm inside_dot_netGc algorithm inside_dot_net
Gc algorithm inside_dot_net
 
WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPedia
 
Finding Logic Bugs in Database Management Systems
Finding Logic Bugs in Database Management SystemsFinding Logic Bugs in Database Management Systems
Finding Logic Bugs in Database Management Systems
 
Hacking oracle using metasploit
Hacking oracle using metasploitHacking oracle using metasploit
Hacking oracle using metasploit
 
interface
interfaceinterface
interface
 

Similar to Software Engineering - RS4

LOGBack and SLF4J
LOGBack and SLF4JLOGBack and SLF4J
LOGBack and SLF4Jjkumaranc
 
LOGBack and SLF4J
LOGBack and SLF4JLOGBack and SLF4J
LOGBack and SLF4Jjkumaranc
 
LOGBack and SLF4J
LOGBack and SLF4JLOGBack and SLF4J
LOGBack and SLF4Jjkumaranc
 
LOGBack and SLF4J
LOGBack and SLF4JLOGBack and SLF4J
LOGBack and SLF4Jjkumaranc
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeMarco Gralike
 
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20Dennis de Greef
 
Logging with Logback in Scala
Logging with Logback in ScalaLogging with Logback in Scala
Logging with Logback in ScalaKnoldus Inc.
 
.NET @ apache.org
 .NET @ apache.org .NET @ apache.org
.NET @ apache.orgTed Husted
 
Swift profiling middleware and tools
Swift profiling middleware and toolsSwift profiling middleware and tools
Swift profiling middleware and toolszhang hua
 
Play framework : A Walkthrough
Play framework : A WalkthroughPlay framework : A Walkthrough
Play framework : A Walkthroughmitesh_sharma
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a bossFrancisco Ribeiro
 
Hadoop Eagle - Real Time Monitoring Framework for eBay Hadoop
Hadoop Eagle - Real Time Monitoring Framework for eBay HadoopHadoop Eagle - Real Time Monitoring Framework for eBay Hadoop
Hadoop Eagle - Real Time Monitoring Framework for eBay HadoopDataWorks Summit
 
Application Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyApplication Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyTim Bunce
 
D2 8 Enhydra Shark
D2 8   Enhydra SharkD2 8   Enhydra Shark
D2 8 Enhydra Sharkbrutkowski
 
Build, logging, and unit test tools
Build, logging, and unit test toolsBuild, logging, and unit test tools
Build, logging, and unit test toolsAllan Huang
 

Similar to Software Engineering - RS4 (20)

LOGBack and SLF4J
LOGBack and SLF4JLOGBack and SLF4J
LOGBack and SLF4J
 
LOGBack and SLF4J
LOGBack and SLF4JLOGBack and SLF4J
LOGBack and SLF4J
 
LOGBack and SLF4J
LOGBack and SLF4JLOGBack and SLF4J
LOGBack and SLF4J
 
LOGBack and SLF4J
LOGBack and SLF4JLOGBack and SLF4J
LOGBack and SLF4J
 
11i Logs
11i Logs11i Logs
11i Logs
 
Logging
LoggingLogging
Logging
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
 
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
Profiling PHP - AmsterdamPHP Meetup - 2014-11-20
 
Logging with Logback in Scala
Logging with Logback in ScalaLogging with Logback in Scala
Logging with Logback in Scala
 
.NET @ apache.org
 .NET @ apache.org .NET @ apache.org
.NET @ apache.org
 
Swift profiling middleware and tools
Swift profiling middleware and toolsSwift profiling middleware and tools
Swift profiling middleware and tools
 
Play framework : A Walkthrough
Play framework : A WalkthroughPlay framework : A Walkthrough
Play framework : A Walkthrough
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
Gohan
GohanGohan
Gohan
 
Hadoop Eagle - Real Time Monitoring Framework for eBay Hadoop
Hadoop Eagle - Real Time Monitoring Framework for eBay HadoopHadoop Eagle - Real Time Monitoring Framework for eBay Hadoop
Hadoop Eagle - Real Time Monitoring Framework for eBay Hadoop
 
Application Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyApplication Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.key
 
Log4j in 8 slides
Log4j in 8 slidesLog4j in 8 slides
Log4j in 8 slides
 
D2 8 Enhydra Shark
D2 8   Enhydra SharkD2 8   Enhydra Shark
D2 8 Enhydra Shark
 
Build, logging, and unit test tools
Build, logging, and unit test toolsBuild, logging, and unit test tools
Build, logging, and unit test tools
 
More about PHP
More about PHPMore about PHP
More about PHP
 

More from AtakanAral

Subgraph Matching for Resource Allocation in the Federated Cloud Environment
Subgraph Matching for Resource Allocation in the Federated Cloud EnvironmentSubgraph Matching for Resource Allocation in the Federated Cloud Environment
Subgraph Matching for Resource Allocation in the Federated Cloud EnvironmentAtakanAral
 
Quality of Service Channelling for Latency Sensitive Edge Applications
Quality of Service Channelling for Latency Sensitive Edge ApplicationsQuality of Service Channelling for Latency Sensitive Edge Applications
Quality of Service Channelling for Latency Sensitive Edge ApplicationsAtakanAral
 
Resource Mapping Optimization for Distributed Cloud Services - PhD Thesis Def...
Resource Mapping Optimization for Distributed Cloud Services - PhD Thesis Def...Resource Mapping Optimization for Distributed Cloud Services - PhD Thesis Def...
Resource Mapping Optimization for Distributed Cloud Services - PhD Thesis Def...AtakanAral
 
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...AtakanAral
 
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...AtakanAral
 
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...AtakanAral
 
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...AtakanAral
 
Software Engineering - RS3
Software Engineering - RS3Software Engineering - RS3
Software Engineering - RS3AtakanAral
 
Software Engineering - RS2
Software Engineering - RS2Software Engineering - RS2
Software Engineering - RS2AtakanAral
 
Software Engineering - RS1
Software Engineering - RS1Software Engineering - RS1
Software Engineering - RS1AtakanAral
 
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Proposal]
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Proposal]Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Proposal]
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Proposal]AtakanAral
 
Analysis of Algorithms II - PS5
Analysis of Algorithms II - PS5Analysis of Algorithms II - PS5
Analysis of Algorithms II - PS5AtakanAral
 
Improving Resource Utilization in Cloud using Application Placement Heuristics
Improving Resource Utilization in Cloud using Application Placement HeuristicsImproving Resource Utilization in Cloud using Application Placement Heuristics
Improving Resource Utilization in Cloud using Application Placement HeuristicsAtakanAral
 
Analysis of Algorithms II - PS3
Analysis of Algorithms II - PS3Analysis of Algorithms II - PS3
Analysis of Algorithms II - PS3AtakanAral
 
Analysis of Algorithms II - PS2
Analysis of Algorithms II - PS2Analysis of Algorithms II - PS2
Analysis of Algorithms II - PS2AtakanAral
 
Analysis of Algorithms - 5
Analysis of Algorithms - 5Analysis of Algorithms - 5
Analysis of Algorithms - 5AtakanAral
 
Analysis of Algorithms - 3
Analysis of Algorithms - 3Analysis of Algorithms - 3
Analysis of Algorithms - 3AtakanAral
 
Analysis of Algorithms - 2
Analysis of Algorithms - 2Analysis of Algorithms - 2
Analysis of Algorithms - 2AtakanAral
 
Analysis of Algorithms - 1
Analysis of Algorithms - 1Analysis of Algorithms - 1
Analysis of Algorithms - 1AtakanAral
 
Mobile Multi-domain Search over Structured Web Data
Mobile Multi-domain Search over Structured Web DataMobile Multi-domain Search over Structured Web Data
Mobile Multi-domain Search over Structured Web DataAtakanAral
 

More from AtakanAral (20)

Subgraph Matching for Resource Allocation in the Federated Cloud Environment
Subgraph Matching for Resource Allocation in the Federated Cloud EnvironmentSubgraph Matching for Resource Allocation in the Federated Cloud Environment
Subgraph Matching for Resource Allocation in the Federated Cloud Environment
 
Quality of Service Channelling for Latency Sensitive Edge Applications
Quality of Service Channelling for Latency Sensitive Edge ApplicationsQuality of Service Channelling for Latency Sensitive Edge Applications
Quality of Service Channelling for Latency Sensitive Edge Applications
 
Resource Mapping Optimization for Distributed Cloud Services - PhD Thesis Def...
Resource Mapping Optimization for Distributed Cloud Services - PhD Thesis Def...Resource Mapping Optimization for Distributed Cloud Services - PhD Thesis Def...
Resource Mapping Optimization for Distributed Cloud Services - PhD Thesis Def...
 
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
 
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
 
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
 
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Progres...
 
Software Engineering - RS3
Software Engineering - RS3Software Engineering - RS3
Software Engineering - RS3
 
Software Engineering - RS2
Software Engineering - RS2Software Engineering - RS2
Software Engineering - RS2
 
Software Engineering - RS1
Software Engineering - RS1Software Engineering - RS1
Software Engineering - RS1
 
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Proposal]
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Proposal]Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Proposal]
Modeling and Optimization of Resource Allocation in Cloud [PhD Thesis Proposal]
 
Analysis of Algorithms II - PS5
Analysis of Algorithms II - PS5Analysis of Algorithms II - PS5
Analysis of Algorithms II - PS5
 
Improving Resource Utilization in Cloud using Application Placement Heuristics
Improving Resource Utilization in Cloud using Application Placement HeuristicsImproving Resource Utilization in Cloud using Application Placement Heuristics
Improving Resource Utilization in Cloud using Application Placement Heuristics
 
Analysis of Algorithms II - PS3
Analysis of Algorithms II - PS3Analysis of Algorithms II - PS3
Analysis of Algorithms II - PS3
 
Analysis of Algorithms II - PS2
Analysis of Algorithms II - PS2Analysis of Algorithms II - PS2
Analysis of Algorithms II - PS2
 
Analysis of Algorithms - 5
Analysis of Algorithms - 5Analysis of Algorithms - 5
Analysis of Algorithms - 5
 
Analysis of Algorithms - 3
Analysis of Algorithms - 3Analysis of Algorithms - 3
Analysis of Algorithms - 3
 
Analysis of Algorithms - 2
Analysis of Algorithms - 2Analysis of Algorithms - 2
Analysis of Algorithms - 2
 
Analysis of Algorithms - 1
Analysis of Algorithms - 1Analysis of Algorithms - 1
Analysis of Algorithms - 1
 
Mobile Multi-domain Search over Structured Web Data
Mobile Multi-domain Search over Structured Web DataMobile Multi-domain Search over Structured Web Data
Mobile Multi-domain Search over Structured Web Data
 

Recently uploaded

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 

Recently uploaded (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 

Software Engineering - RS4

  • 1. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References BLG 411E – Software Engineering Recitation Session 4 Application Logging and Object-Relational Mapping Atakan Aral, Bilge Süheyla Akkoca 02.12.2014
  • 2. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Outline 1 Logging Log4j 2 ORM Hibernate 3 References
  • 3. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Application Logging Introduction Definition Recording the events which happen during a software execution. Logging allows to: audit important items, analyze application use, trace errors. Performance is the most important consideration.
  • 4. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Application Logging Logging Levels OFF No logging FATAL Only errors that cause the application to abort ERROR Critical errors that prevent the use case from continuing WARN Other errors and exceptions where processes may still continue, i.e. “Current data unavailable, using cached values” INFO Life cycle events, completion of use cases, i.e. “[Who] booked ticket from [Where] to [Where]” DEBUG All other (sub) events TRACE All method invocations with parameter and return values
  • 5. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Application Logging Tips Apply logging levels appropriately Avoid side effects (no impact on the application’s behavior) Log for easy reading and easy parsing Include both data and description, no magic numbers or characters (i.e. &&&) Use a logging pattern (i.e. %d{HH:mm:ss.SSS} %-5level [%thread][%logger{0}] %m%n) Maximize logging for external systems Maximize logging when in trouble, not otherwise Avoid excessive string concatenation, use parametrized logging methods Do not log sensitive information
  • 6. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Log4j Introduction Definition A Java-based logging utility which provides performance improvements and advanced filtering. import org . apache . logging . l o g 4 j . LogManager ; import org . apache . logging . l o g 4 j . Logger ; public class HelloWorld { pr ivate s t a t i c f i n a l Logger l = LogManager . getLogger ( " HelloWorld " ) ; public s t a t i c void main ( St r i n g [ ] args ) { l . i n f o ( " Hello , World ! " ) ; l . e r r o r ( " Mission f a i l e d ! " ) ; } }
  • 7. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Object-Relational Mapping Definitions Persistence Application’s data to outlive the applications process, state of objects to live beyond the scope of the JVM so that the same state is available later DMSs Although ODBMSs are emerging, RDBMSs are still the most popular ones. Paradigm mismatch Object models (i.e. Java) and relational models (i.e. SQL) do not work very well together. See the next slide for the details. ORM A programming technique for converting data between the two incompatible type systems
  • 8. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Object-Relational Mapping Object-relational impedance mismatch RDBMSs represent data in a tabular format where object-oriented languages represent it as an inter-connected graph of objects. Mismatch problems: Granularity Object model usually has more classes than the number of corresponding tables in the database. Subtypes Inheritance in OOP does not exist in RDBMSs. Identity OOP supports identity (a == b) and equality (a:equals(b)) while RDBMSs only support identity (the primary key). Association References vs. foreign keys Navigation In OOP, navigation is from one association to another, walking the object network. That is inefficient in RDBMSs, so JOINs are used.
  • 9. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Hibernate Introduction Definition Hibernate is an ORM library for Java that solves object-relational impedance mismatch problems by replacing direct persistence-related DB access with high-level object handling functions. Allows developer to concentrate on Java code instead of complex SQL statements. Reduces the lines of code, makes the system more understandable and easier to maintain. Abstracts the application away from the underlying SQL database and dialect, fosters portability.
  • 10. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Hibernate Hibernate mapping file Class–Table Property–Id Property–Column Types and column names are optional. <hibernatemapping class name= Product tab l e =PRODUCTS i d name= product Id column= pid generator class= assigned / / i d proper t y name=proName column=pname / proper t y name= p r i c e / proper t y name= date type= timestamp column= creat ion_date / / class / hibernatemapping
  • 11. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Hibernate Hibernate configuration file JDBC connection information (connection.driver_class, connection.username, connection.password, connection.url) Number of connections (connection.pool_size) SQL variant (dialect) DB schema generation (hbm2ddl.auto) Mapping persistent classes (mapping)
  • 12. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Hibernate Hibernate configuration file hibernatec o n f i g u r a t i o n sessionf a c t o r y proper t y name= connect ion . d r i v e r _ c l a s s oracle . jdbc . d r i v e r . OracleDr iver / proper t y proper t y name= connect ion . u r l jdbc:oracle: thin:@www . java4s . com:1521:XE / proper t y proper t y name= connect ion . user user / proper t y proper t y name= connect ion . password password / proper t y proper t y name= show_sql t rue / proper t y proper t y name= d i a l e c t org . hibernate . d i a l e c t . Orac leDialec t / proper t y proper t y name= hbm2ddl . auto update / proper t y mapping resource= product .hbm. xml / / sessionf a c t o r y / hibernatec o n f i g u r a t i o n
  • 13. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Hibernate Sample program code import org . hibernate . ; import org . hibernate . cfg . ; public class Cl ientForSave { public s t a t i c void main ( St r i n g [ ] args ) { Conf igurat ion cfg = new Conf igurat ion ( ) ; cfg . conf igure ( hibernate . cfg . xml ) ; SessionFactory f a c t o r y = cfg . bui ldSessionFactory ( ) ; Session session = f a c t o r y . openSession ( ) ; Product p = new Product ( ) ; p . setProduct Id ( 1 0 1 ) ; p . setProName ( iPhone ) ; p . setPr i ce (25000) ; p . setDate (new Date ( ) ) ; session . beginTransact ion ( ) ; session . save ( p ) ; session . getTransact ion ( ) . commit ( ) ; session . close ( ) ; f a c t o r y . close ( ) ; } }
  • 14. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References Hibernate Sample program code session = sessionFactory . openSession ( ) ; session . beginTransact ion ( ) ; L i s t r e s u l t = session . createQuery ( from PRODUCTS ) . l i s t ( ) ; for ( Product p : ( L i s t Product ) r e s u l t ) { System. out . p r i n t l n ( Product ( + p . setProduct Id ( ) + ) : + p . setProName ( ) ) ; } session . getTransact ion ( ) . commit ( ) ; session . close ( ) ;
  • 15. BLG 411E Software Engineering Recitation 4 Logging Log4j ORM Hibernate References References and Further Reading http://www.javacodegeeks.com/2011/01/ 10-tips-proper-application-logging.html http: //blogg.kantega.no/logging-in-java-with-users-in-mind/ http://logging.apache.org/log4j/2.x/ http://www.agiledata.org/essays/impedanceMismatch.html http://hibernate.org/orm/ http://www.java4s.com/hibernate/ hibernate-hello-world-program-saving-an-objcet/