From xsd to database. How?

My main goal is to download the xml ISO19115-2 and store it in the database.

With the Generate hibernate beans from XSD , I created all the classes and I can read the xml and unmarshalling in Java.

Now I would like to create a database schema (NB there are 900+ classes).

I thought the solution could use hibernate to map and store objects in the db.

I created the mapping files hbm.xml but hibernate doesn't like them giving errors like this:

org.hibernate.MappingException: Foreign key (FK9C4C4E4C6991863A:DIRECTPOSITIONTYPE [LOWERCORNER])) must have same number of columns as the referenced primary key (ENVELOPETYPE [LOWERCORNER,idx])

      

and there are thousands of these errors.

Having jaxb annotated classes, is there any other way to get the database schema?

Also note that using this tool http://xsd2db.sourceforge.net/ is not a solution as I want to load xml from java and I can "t manually create a mapping for all classes.

+3


source to share


1 answer


here.

I am familiar with ISO 19115 schemas, I would definitely not recommend storing XML instances of these documents in a relational database. A few years ago I developed a geodata management product that (in particular) did just that (storing ISO 19115 in a relational database), and now, a few years later, I would argue that this is the wrong design.



I was able to get Hyperjaxb to work on ISO 19115 schemes, so in principle it works. But I finally figured out that storing ISO 19115 data structurally in a normalized database schema doesn't make much sense. Typically ISO 19115 documents are available through CSW interfaces using filter encoding as the query language. Filter coding mostly uses expressions based on "properties" ( ogc:PropertyIsLike

etc.). So finally it was much better to just index each XML instance on top of the supported properties. You don't need an ISO 19115 Structural Data Warehouse for this.

I guess it doesn't answer your question, but I was there, did it, and I won't do it the way you want to do it.

+3


source







All Articles