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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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'
 

Destaque

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
 

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

Semelhante 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
 

Semelhante 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

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
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
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Último (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

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