@@ -315,6 +315,59 @@ specified by the `<fileset>` to avoid duplicate import exceptions.
315
315
316
316
### 2.2 JPA Configuration
317
317
318
+ The second possibility to configure the ` <hibernatetool> ` task is by using the ` <jpaconfiguration> `
319
+ element. A ` <jpaconfiguration> ` tag is used when you want to read the metamodel from JPA.
320
+ In other words, when you do not have a ` hibernate.cfg.xml ` , but instead have a setup where
321
+ you use a ` persistence.xml ` file packaged in a JPA compliant manner.
322
+
323
+ ``` xml
324
+ <target name =" reveng" >
325
+ <hibernatetool destdir =" ..." >
326
+ ...
327
+ <jpaconfiguration />
328
+ ...
329
+ </hibernatetool >
330
+ </target >
331
+ ```
332
+
333
+ The ` <jpaconfiguration> ` tag will try and auto-configure it self based on the available classpath,
334
+ e.g. look for the ` META-INF/persistence.xml ` file.
335
+
336
+ ### 2.2.1 The ` persistenceunit ` attribute
337
+
338
+ The ` persistenceunit ` attribute can be used to select a specific persistence unit. In the
339
+ xml excerpt below, the persistence unit called 'bar' will be selected.
340
+
341
+ ``` xml
342
+ <target name =" reveng" >
343
+ <hibernatetool destdir =" ..." >
344
+ ...
345
+ <jpaconfiguration persistenceunit =" bar" />
346
+ ...
347
+ </hibernatetool >
348
+ </target >
349
+ ```
350
+
351
+ If no ` persistenceunit ` attribute is specified Hibernate Tools will automatically search for one,
352
+ and if a unique one is found, use it. However, having multiple persistence units will result in an error.
353
+
354
+ ### 2.2.2 Additional Configuration
355
+
356
+ As the ` <jpaconfiguration> ` element inherits all the configuration elements and attributes above
357
+ are theoretically applicable.
358
+
359
+ #### 2.2.2.1 The ` propertyfile ` attribute
360
+
361
+ See section 2.1.1
362
+
363
+ #### 2.2.2.2 The ` configurationfile ` attribute
364
+
365
+ This attribute will result in an exception as the configuration is read from the ` persistence.xml ` file.
366
+
367
+ #### 2.2.2.3 The ` <fileset> ` element
368
+
369
+ This nested element is ignored.
370
+
318
371
### 2.3 JDBC Configuration
319
372
320
373
## 3. The Hibernate Tools Exporters
0 commit comments