SlideShare una empresa de Scribd logo
1 de 5
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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 のアーキテクチャーと RxHttpClientShinya 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_differentdefenseschemesCanSecWest
 
Python twisted
Python twistedPython twisted
Python twistedMahendra 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 lab4Benux Wei
 
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 DumpsAndrei Pangin
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scriptingTony Fabeen
 
Java Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVMJava Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVModnoklassniki.ru
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueGleicon Moraes
 
[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 UPYUNCong Zhang
 
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
 

La actualidad más candente (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'
 

Destacado

Woody's Quotes
Woody's QuotesWoody's Quotes
Woody's Quotesoksana1
 
JD James - What we do
JD James - What we do JD James - What we do
JD James - What we do JD James & Co.
 
第七颗头骨 & 忘魂花 凤凰
第七颗头骨 & 忘魂花 凤凰第七颗头骨 & 忘魂花 凤凰
第七颗头骨 & 忘魂花 凤凰yifi2009
 
Photo Album2
Photo Album2Photo Album2
Photo Album2renies
 
Photo Album1
Photo Album1Photo Album1
Photo Album1renies
 
Skritter @ IALLT
Skritter @ IALLTSkritter @ IALLT
Skritter @ IALLTguest5fb7b6
 

Destacado (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 a Hibernate Import.Sql I18n

JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 SpringKiyotaka Oku
 
Mobile Programming - Network Universitas Budi Luhur
Mobile Programming - Network Universitas Budi LuhurMobile Programming - Network Universitas Budi Luhur
Mobile Programming - Network Universitas Budi LuhurRiza Fahmi
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
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 JVMRafael Winterhalter
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bChereCheek752
 
Jdk 7 4-forkjoin
Jdk 7 4-forkjoinJdk 7 4-forkjoin
Jdk 7 4-forkjoinknight1128
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programmingAnung Ariwibowo
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles 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 gradleThierry 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
 
Atlassian Groovy Plugins
Atlassian Groovy PluginsAtlassian Groovy Plugins
Atlassian Groovy PluginsPaul King
 

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

Último

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

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