0

Part 1:

I have a model.hbm.xml file that is often update, which currently requires a full project build and deployment whenever it is modified.

Can I break this out, so that the model.hbm.xml is read from the file-system, or a remote location (i.e. \file server\C$\Path\To\Hibernate\Mappings) when the application starts?

Currently I'm loading it from persistence.xml with <mapping-file>model.hbm.xml</mapping-file>

Part 2:

What I really want is to load all *.hbm.xml files from a specified directory when the application starts.

Is there any wildcard/directory support for loading hibernate mappings?


Update:

I've found a semi-solution to loading the mapping-file from a remote location

<mapping-file>file:////FileServerIP/path/to/hbm/model.hbm.xml</mapping-file>

Allows me to store the mapping file outside of the build, in a place where all servers have access.

I would like to implement this using a .properties file, so that the FileServerIP can be independent of the build as well. I haven't found out how to do that yet.

My simple attempts at loading directories/wildcards have also been unfruitful.

<mapping-file>file:////FileServerIP/path/to/hbm/*.hbm.xml</mapping-file>
<mapping-file>file:////FileServerIP/path/to/hbm/</mapping-file>

Both failed to load the model.hbm.xml file.

Jamie
  • 168
  • 10
  • Have you tried `*.hbm.xml` ? – Zorglube Nov 27 '17 at 16:39
  • I've tried with `file:///C:/tmp/hbm/*.hbm.xml`, which didn't work. Although `file:///C:/tmp/hbm/model.hbm.xml` did work. – Jamie Nov 27 '17 at 21:18
  • Maybe something here https://stackoverflow.com/questions/1947720/spring-hibernate-load-hbm-xml-from-classpath-resource – Zorglube Nov 28 '17 at 10:12
  • I didn't see anything there that would help, they are still trying to explicitly load each mapping-file. I'm wondering if I can move my mapping files into a .jar, and load them during application boot from a remote location like `file:////FileServerIP/path/to/jar/apphbm.jar` but I'm not sure where to get started. – Jamie Nov 29 '17 at 14:47

0 Answers0