Reputation: 1965
My main goal is to load a xml of ISO19115-2 and store it into a database.
With this Generate hibernate entity beans from XSD i created all the classes and I can read the xml and unmarshalling in Java.
Now what I would like to do is generate the database schema (NB there are 900+ classes).
I thought that the solution could be using hibernate to map and store objects into the db.
I've created the hbm.xml mapping files 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 another way to obtain a database schema?
Also note that using tool like this http://xsd2db.sourceforge.net/ is not a solution as I want to load the xml from java and I can't manually create the mapping for all the classes.
Upvotes: 3
Views: 477
Reputation: 43661
hyperjaxb author here.
I know ISO 19115 schemas quite well, I would definitely not recommend saving XML instances of these documents in a relational database. Few years ago I've developed a geo-metadata management product which (among others) did exactly this (saving ISO 19115 in a relational database), and now, a few years later I'd really say - this is not the right design.
I did manage to make Hyperjaxb work for ISO 19115 schemas back then, so in principle this works. But I've finally found out that saving ISO 19115 data structurally in a normalized database schema does not make much sense. ISO 19115 documents are normally accessed via CSW interfaces using Filter Encoding as query language. Filter Encoding mostly uses expressions based on "properties" (ogc:PropertyIsLike
etc.). So it was finally much better to just index each XML instance over the supported properties. You don't really need structural storage of ISO 19115 data for this.
I guess this does not answer your question, but I've been there, done that, and I won't do it as you want to do it.
Upvotes: 3