Вы можете определить и связать сценарии SQL в определении контекста постоянства JPA, которое будет выполняться во время выполнения. Существуют стандартизированные свойства для определения сценариев, как создавать схему, загружать данные и отбрасывать схему соответственно:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
|
< span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >< persistence version = "2.1" xmlns = "http://xmlns.jcp.org/xml/ns/persistence" </span> < persistence version = "2.1" xmlns = "http://xmlns.jcp.org/xml/ns/persistence" </span> < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</ span > XMLNS: XSI = "http://www.w3.org/2001/XMLSchema-instance"</ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence</ span > XSI: SchemaLocation = "http://xmlns.jcp.org/xml/ns/persistence</ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"></ span > http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd "></ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >< persistence-unit name = "prod" transaction-type = "JTA" ></ span > < persistence-unit name = "prod " action-type = " JTA " ></ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >< properties ></ span > <свойства></ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >< property name = "javax.persistence.schema-generation.database.action" </span> < property name = "javax.persistence.schema-generation.database.action" </span> < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >value="drop-and-create"/></ span > Значение = «ответвление и создать» /></ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >< property name = "javax.persistence.schema-generation.create-script-source" </span> < property name = "javax.persistence.schema-generation.create-script-source" </span> < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >value="create-schema.sql" /></ span > value = "create-schema.sql" /></ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >< property name = "javax.persistence.schema-generation.sql-load-script-source" </span> < property name = "javax.persistence.schema-generation.sql-load-script-source" </span> < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >value="load-data.sql" /></ span > value = "load-data.sql" /></ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >< property name = "javax.persistence.schema-generation.drop-script-source" </span> < property name = "javax.persistence.schema-generation.drop-script-source" </span> < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" >value="drop-schema.sql" /></ span > value = "drop-schema.sql" /></ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" ></ properties ></ span > </ Недвижимость></ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" ></ persistence-unit ></ span > </ Сохранение-блок></ span > < span class = "notranslate" onmouseover = "_tipon(this)" onmouseout = "_tipoff()" >< span class = "google-src-text" style = "direction: ltr; text-align: left" ></ persistence ></ span > </ Сохранение></ span > |
Ожидается, что файлы SQL будут находиться в пути к классам.
Это сообщение было размещено в моем выпуске новостей 004
Опубликовано на Java Code Geeks с разрешения Себастьяна Дашнера, партнера нашей программы JCG. См. Оригинальную статью здесь: JPA persistence.xml Определения SQL-скрипта
Мнения, высказанные участниками Java Code Geeks, являются их собственными. |