SlideShare a Scribd company logo
hibernate                                   sql           import.sql




          LTEX Documented By
          A                                      http://blog.csdn.net/shadowkiss

                                               2009-7-6


                        Hibernate                                 ddl                      im-
    port.sql                classpath                                         hibernate.cfg.xml


1   < property name = " hbm2ddl . auto " > create </ property >
2   or
3   < property name = " hbm2ddl . auto " > create - drop </ property >


                      import.sql                              JVM                 file.encoding
                                        *nix
                  Windows           OS                                                 JVM
               -Dfile.encoding=UTF-8                                 console

                                           UTF-8
                                                          SchemaExport.java :
1   package org . hibernate . tool . hbm2ddl ;
2   ...
3   public class SchemaExport {
4   ...
5         public void execute ( boolean script , boolean export , boolean
               justDrop , boolean justCreate ) {

                                                  1
6   ...
7                           InputStream stream = ConfigHelper .
                                 getResourc e AsSt r eam ( importFile ) ;
8                           importFileReader = new InputS treamR eader ( stream ) ;
9   ...


                                    Hibernate                   JVM                             (
    new InputStreamReader                                  )       SchemaExport




      (I)      classpath                   import.sql.UTF-8


     (II)                                                          import.sql


       1    package cn . qdqn . bms . web . listener ;
       2
       3    import java . io . File ;
       4    import java . io . FileOutputStream ;
       5    import java . io . IOException ;
       6    import java . io . InputStreamReader ;
       7    import java . io . OutputSt re amWrit er ;
       8    import java . io . Reader ;
       9    import java . io . Writer ;
      10    import java . net . URI ;
      11    import java . net . URISyntaxE xc eption ;
      12
      13    import javax . servlet . Ser vlet C onte x tE v e nt ;
      14    import javax . servlet . S er v l e t Co n te x t L i s t e n e r ;
      15
      16    public class HibListener implements S e r v l e t C o n t e x t L i s t e n e r {
      17
      18          /* *
      19              *
      20              */
      21          public void contextDestroyed ( Se r v le t C on t e xt E v en t sce ) {
      22
      23          }


                                                      2
24
25   /* *
26    *
27    */
28   public void contextIn it ialize d ( S er v l et C o nt e x tE v e nt sce ) {
29          String fileName = sce . getSe rvletC ontext () .
                 getInitParameter ( " ddl " ) ;
30          sce . getServletContext () . log ( " Convert " + fileName + "
                 to import . sql " ) ;
31          String srcEnc = fileName . substring ( fileName .
                 lastIndexOf ( " . " ) + 1) ;
32          //      import.sql
33          File importsqlfile = null ;
34          try {
35                importsqlfile = new File ( new URI ( Thread .
                      currentThread ()
36                          . ge t Con tex t Cl a s s L o a d e r () . getResource ( " " )
37                          + " import . sql " ) ) ;
38          } catch ( URISynt ax Except io n e ) {
39                e . printStackTrace () ;
40          }
41
42          //
43          Reader reader = null ;
44          Writer writer = null ;
45          try {
46                reader = new InputStreamR eader ( Thread .
                      currentThread ()
47                          . ge t Con tex t Cl a s s L o a d e r () .
                                 ge tRes o urce A sS t r ea m ( fileName ) ,
48                          srcEnc ) ;
49
50                writer = new OutputS tr ea mW ri te r (
51                          new FileOutputStream ( importsqlfile ) ,
                                 System
52                                       . getProperty ( " file . encoding " ) ) ;
53
54                int c = -1;
55                StringBuffer tempSB = new StringBuffer () ;
56                while (( c = reader . read () ) != -1) {


                                         3
57                               writer . write ( c ) ;
 58                               tempSB . append (( char ) c ) ;
 59                          }
 60                          sce . getServlet Contex t () . log ( tempSB . toString () ) ;
 61                          //
 62                          sce . getServlet Contex t () . log (
 63                                     " Generate import . sql ( "
 64                                                + System . getProperty ( " file .
                                                        encoding " )
 65                                                + " ) success ! " ) ;
 66                     } catch ( Exception e ) {
 67                          e . printStackTrace () ;
 68                     } finally {
 69                          try {
 70                               reader . close () ;
 71                               writer . flush () ;
 72                               writer . close () ;
 73                          } catch ( IOException e ) {
 74                               e . printStackTrace () ;
 75                          }
 76                     }
 77             }
 78
 79     }


(III)           web.xml                                                      SessionFactory
            ,   ssh                       Spring ContextLoaderListener
  1             <! --                hibernate ddl                     import.sql -- >
  2             <! --                                      -- >
  3             < context - param >
  4                     < param - name > ddl </ param - name >
  5                     < param - value > import . sql . UTF -8 </ param - value >
  6             </ context - param >
  7             < listener >
  8                     < listener - class >
  9                          cn . qdqn . bms . web . listener . HibListener
 10                     </ listener - class >
 11             </ listener >




                                                   4
5

More Related Content

What's hot

Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Vert.X: Microservices Were Never So Easy (Clement Escoffier)Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Red Hat Developers
 
Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD
Giovanni Bechis
 
swift-nio のアーキテクチャーと RxHttpClient
swift-nio のアーキテクチャーと RxHttpClientswift-nio のアーキテクチャーと RxHttpClient
swift-nio のアーキテクチャーと RxHttpClient
Shinya Mochida
 
Do we need Unsafe in Java?
Do we need Unsafe in Java?Do we need Unsafe in Java?
Do we need Unsafe in Java?
Andrei Pangin
 
Csw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCsw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemes
CanSecWest
 
Python twisted
Python twistedPython twisted
Python twisted
Mahendra M
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)
Giovanni Bechis
 
Preparation for mit ose lab4
Preparation for mit ose lab4Preparation for mit ose lab4
Preparation for mit ose lab4
Benux Wei
 
OWASP Proxy
OWASP ProxyOWASP Proxy
OWASP Proxy
Security B-Sides
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap Dumps
Andrei Pangin
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
Tony Fabeen
 
Java Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVMJava Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVM
odnoklassniki.ru
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
Gleicon Moraes
 
PostgreSQL and PL/Java
PostgreSQL and PL/JavaPostgreSQL and PL/Java
PostgreSQL and PL/Java
Peter Eisentraut
 
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
GangSeok Lee
 
Using ngx_lua in UPYUN
Using ngx_lua in UPYUNUsing ngx_lua in UPYUN
Using ngx_lua in UPYUN
Cong Zhang
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
Felix Geisendörfer
 
Nginx-lua
Nginx-luaNginx-lua
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Tzung-Bi Shih
 
From 'dotnet run' to 'hello world'
From 'dotnet run' to 'hello world'From 'dotnet run' to 'hello world'
From 'dotnet run' to 'hello world'
Matt Warren
 

What's hot (20)

Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Vert.X: Microservices Were Never So Easy (Clement Escoffier)Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Vert.X: Microservices Were Never So Easy (Clement Escoffier)
 
Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD Relayd: a load balancer for OpenBSD
Relayd: a load balancer for OpenBSD
 
swift-nio のアーキテクチャーと RxHttpClient
swift-nio のアーキテクチャーと RxHttpClientswift-nio のアーキテクチャーと RxHttpClient
swift-nio のアーキテクチャーと RxHttpClient
 
Do we need Unsafe in Java?
Do we need Unsafe in Java?Do we need Unsafe in Java?
Do we need Unsafe in Java?
 
Csw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCsw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemes
 
Python twisted
Python twistedPython twisted
Python twisted
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)
 
Preparation for mit ose lab4
Preparation for mit ose lab4Preparation for mit ose lab4
Preparation for mit ose lab4
 
OWASP Proxy
OWASP ProxyOWASP Proxy
OWASP Proxy
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap Dumps
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
 
Java Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVMJava Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVM
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
 
PostgreSQL and PL/Java
PostgreSQL and PL/JavaPostgreSQL and PL/Java
PostgreSQL and PL/Java
 
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
 
Using ngx_lua in UPYUN
Using ngx_lua in UPYUNUsing ngx_lua in UPYUN
Using ngx_lua in UPYUN
 
Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)Nodejs - A quick tour (v6)
Nodejs - A quick tour (v6)
 
Nginx-lua
Nginx-luaNginx-lua
Nginx-lua
 
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
 
From 'dotnet run' to 'hello world'
From 'dotnet run' to 'hello world'From 'dotnet run' to 'hello world'
From 'dotnet run' to 'hello world'
 

Viewers also liked

Woody's Quotes
Woody's QuotesWoody's Quotes
Woody's Quotes
oksana1
 
JD James - What we do
JD James - What we do JD James - What we do
JD James - What we do
JD James & Co.
 
第七颗头骨 & 忘魂花 凤凰
第七颗头骨 & 忘魂花 凤凰第七颗头骨 & 忘魂花 凤凰
第七颗头骨 & 忘魂花 凤凰yifi2009
 
Science
ScienceScience
Science
guestd1d6e1
 
Photo Album2
Photo Album2Photo Album2
Photo Album2
renies
 
Photo Album1
Photo Album1Photo Album1
Photo Album1
renies
 
Skritter @ IALLT
Skritter @ IALLTSkritter @ IALLT
Skritter @ IALLT
guest5fb7b6
 

Viewers also liked (8)

Woody's Quotes
Woody's QuotesWoody's Quotes
Woody's Quotes
 
JD James - What we do
JD James - What we do JD James - What we do
JD James - What we do
 
第七颗头骨 & 忘魂花 凤凰
第七颗头骨 & 忘魂花 凤凰第七颗头骨 & 忘魂花 凤凰
第七颗头骨 & 忘魂花 凤凰
 
Science
ScienceScience
Science
 
Photo Album2
Photo Album2Photo Album2
Photo Album2
 
Photo Album1
Photo Album1Photo Album1
Photo Album1
 
Skritter @ IALLT
Skritter @ IALLTSkritter @ IALLT
Skritter @ IALLT
 
Gallery
GalleryGallery
Gallery
 

Similar to Hibernate Import.Sql I18n

JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
Kiyotaka Oku
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
Thierry Wasylczenko
 
Mobile Programming - Network Universitas Budi Luhur
Mobile Programming - Network Universitas Budi LuhurMobile Programming - Network Universitas Budi Luhur
Mobile Programming - Network Universitas Budi Luhur
Riza Fahmi
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
Azul Systems, Inc.
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
Jonathan Waller
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
Rafael Winterhalter
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
ChereCheek752
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
knight1128
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
Anung Ariwibowo
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
Charles Nutter
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
Thierry Wasylczenko
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
Doug Hawkins
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Charles Nutter
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
Scott Leberknight
 
Jersey Guice AOP
Jersey Guice AOPJersey Guice AOP
Jersey Guice AOP
Domenico Briganti
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
Alex Tumanoff
 
Multithreading in Java
Multithreading in JavaMultithreading in Java
Multithreading in Java
Appsterdam Milan
 
Code red SUM
Code red SUMCode red SUM
Code red SUM
Shumail Haider
 
Bhaloo
BhalooBhaloo
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy Plugins
Paul King
 

Similar to Hibernate Import.Sql I18n (20)

JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
Mobile Programming - Network Universitas Budi Luhur
Mobile Programming - Network Universitas Budi LuhurMobile Programming - Network Universitas Budi Luhur
Mobile Programming - Network Universitas Budi Luhur
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
 
A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoin
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
 
Jersey Guice AOP
Jersey Guice AOPJersey Guice AOP
Jersey Guice AOP
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 
Multithreading in Java
Multithreading in JavaMultithreading in Java
Multithreading in Java
 
Code red SUM
Code red SUMCode red SUM
Code red SUM
 
Bhaloo
BhalooBhaloo
Bhaloo
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy Plugins
 

Recently uploaded

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 

Recently uploaded (20)

Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 

Hibernate Import.Sql I18n

  • 1. hibernate sql import.sql LTEX Documented By A http://blog.csdn.net/shadowkiss 2009-7-6 Hibernate ddl im- port.sql classpath hibernate.cfg.xml 1 < property name = " hbm2ddl . auto " > create </ property > 2 or 3 < property name = " hbm2ddl . auto " > create - drop </ property > import.sql JVM file.encoding *nix Windows OS JVM -Dfile.encoding=UTF-8 console UTF-8 SchemaExport.java : 1 package org . hibernate . tool . hbm2ddl ; 2 ... 3 public class SchemaExport { 4 ... 5 public void execute ( boolean script , boolean export , boolean justDrop , boolean justCreate ) { 1
  • 2. 6 ... 7 InputStream stream = ConfigHelper . getResourc e AsSt r eam ( importFile ) ; 8 importFileReader = new InputS treamR eader ( stream ) ; 9 ... Hibernate JVM ( new InputStreamReader ) SchemaExport (I) classpath import.sql.UTF-8 (II) import.sql 1 package cn . qdqn . bms . web . listener ; 2 3 import java . io . File ; 4 import java . io . FileOutputStream ; 5 import java . io . IOException ; 6 import java . io . InputStreamReader ; 7 import java . io . OutputSt re amWrit er ; 8 import java . io . Reader ; 9 import java . io . Writer ; 10 import java . net . URI ; 11 import java . net . URISyntaxE xc eption ; 12 13 import javax . servlet . Ser vlet C onte x tE v e nt ; 14 import javax . servlet . S er v l e t Co n te x t L i s t e n e r ; 15 16 public class HibListener implements S e r v l e t C o n t e x t L i s t e n e r { 17 18 /* * 19 * 20 */ 21 public void contextDestroyed ( Se r v le t C on t e xt E v en t sce ) { 22 23 } 2
  • 3. 24 25 /* * 26 * 27 */ 28 public void contextIn it ialize d ( S er v l et C o nt e x tE v e nt sce ) { 29 String fileName = sce . getSe rvletC ontext () . getInitParameter ( " ddl " ) ; 30 sce . getServletContext () . log ( " Convert " + fileName + " to import . sql " ) ; 31 String srcEnc = fileName . substring ( fileName . lastIndexOf ( " . " ) + 1) ; 32 // import.sql 33 File importsqlfile = null ; 34 try { 35 importsqlfile = new File ( new URI ( Thread . currentThread () 36 . ge t Con tex t Cl a s s L o a d e r () . getResource ( " " ) 37 + " import . sql " ) ) ; 38 } catch ( URISynt ax Except io n e ) { 39 e . printStackTrace () ; 40 } 41 42 // 43 Reader reader = null ; 44 Writer writer = null ; 45 try { 46 reader = new InputStreamR eader ( Thread . currentThread () 47 . ge t Con tex t Cl a s s L o a d e r () . ge tRes o urce A sS t r ea m ( fileName ) , 48 srcEnc ) ; 49 50 writer = new OutputS tr ea mW ri te r ( 51 new FileOutputStream ( importsqlfile ) , System 52 . getProperty ( " file . encoding " ) ) ; 53 54 int c = -1; 55 StringBuffer tempSB = new StringBuffer () ; 56 while (( c = reader . read () ) != -1) { 3
  • 4. 57 writer . write ( c ) ; 58 tempSB . append (( char ) c ) ; 59 } 60 sce . getServlet Contex t () . log ( tempSB . toString () ) ; 61 // 62 sce . getServlet Contex t () . log ( 63 " Generate import . sql ( " 64 + System . getProperty ( " file . encoding " ) 65 + " ) success ! " ) ; 66 } catch ( Exception e ) { 67 e . printStackTrace () ; 68 } finally { 69 try { 70 reader . close () ; 71 writer . flush () ; 72 writer . close () ; 73 } catch ( IOException e ) { 74 e . printStackTrace () ; 75 } 76 } 77 } 78 79 } (III) web.xml SessionFactory , ssh Spring ContextLoaderListener 1 <! -- hibernate ddl import.sql -- > 2 <! -- -- > 3 < context - param > 4 < param - name > ddl </ param - name > 5 < param - value > import . sql . UTF -8 </ param - value > 6 </ context - param > 7 < listener > 8 < listener - class > 9 cn . qdqn . bms . web . listener . HibListener 10 </ listener - class > 11 </ listener > 4
  • 5. 5