Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We need to dynamically create hibernate layers from shapefiles. As far as we understand, the workflow is following:

  1. Import shapefile to database(creating new table for each shapefile?) Is it good approach?
  2. Dynamically create hibernate entity from the table
  3. Make the Entity visible for the Hibernate mechanism
  4. Create Hibernate layer in runtime

Are we moving in the right way? How would you handle our problem?

Is it good approach to creating new table for each shapefile? If it so, how can resolve steps 2-4.

share|improve this question
up vote 1 down vote accepted

The approach you suggest seems to be difficult. I see a couple of things you need to find a solution for.

  • (2) When dynamically creating Hibernate entities, you would need some classloader magic to make them available in the running application. This would need to be done in a Spring aware/compatieble way. Don't know is there are easy solutions to this.

  • (3) is releated to (2), don't know how you can re-init Hibernate to make this work.

  • (4) is currently not possible though there is a plug-in in the sandbox to make dynamic loading of layers possible (have not tried it yet, so I am unsure of the state of this work).

However, in the Ktunaxa RMS project, we handled something similar by having one table for all the features from shape files and a linked table for the attributes. This makes it possible to add data in the layer at runtime and still access all the attributes. See the Ktunaxa project ( for inspiration. Geomajas allows mixed geometry types so there is no worry there.

If you use caching and/or rasterizing) you would need to make sure that the cache is invalidated when you add data in this layer.

Though there are some downsides to this approach, it is by far the easiest way I can image to handle this kind of problem in Geomajas using released components.

share|improve this answer
Joachim, thanks for the answer. I need some time to investigate on the problem before next part of questions. – dementiev May 3 '12 at 19:55

I knew it was possible in .NET + NHibernate, so I did a quick search, and it certainly seems possible in Java + Hibernate as well using Dynamic Models. You will have to generate your Hibernate configuration file at runtime and reload the configuration, and then use a hash to access property values.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.