Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This is a very special question, I hope that somebody here already worked in a similar project setup.

I am working with Netbeans and started a maven web project based upon the maven HS 4.x tutorial on http://www.hibernatespatial.org/tutorial-hs4.html

This compiles fine using maven.

Next I want to use the maven hibernate3 plugin from MOJO (http://mojo.codehaus.org/hibernate3-maven-plugin/index.html), so I can create SQL Scripts and the database schema out of my java entitiy classes. So the workflow should be

  1. code java entitiy classes with spatial (postgis) fields
  2. compile
  3. create DDL out of entity classes
  4. create/update database schema with DDL
  5. run app

The problem is, when I run

mvn hibernate3:hbm2ddl

The plugin does not search for hibernate spatial in the remote repo on www.hibernatespatial.org like the compile plugin does, but searches for it in the central repo. Due to the fact, that the hibernate-spatial.jar does not exist there, DDL creation fails. This is what the maven output looks like:

[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2ddl ... Plugin org.codehaus.mojo:hibernate3-maven-plugin:2.2 or one of its dependencies could not be resolved: Could not find artifact org.hibernate:hibernate-spatial:jar:4.0-M1 in central (http://repo.maven.apache.org/maven2) -> [Help 1]
...
Caused by: ... Could not find artifact org.hibernate:hibernate-spatial:jar:4.0-M1 in central (http://repo.maven.apache.org/maven2)
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

As I already mentioned, maven compile goal works and resolves hibernate-spatial correctly.

Is there an alternative way to create database schema out of java entity classes without the maven hibernate plugin?

share|improve this question
add comment

1 Answer

Ok, problem was a wrong hibernate version in the first place, but also wrong use of hibernate3 plugin with hibernate4, and some missing hibernate4 libraries. Got it working now without the maven plugin, based on the correct use of JPA EntityManager and auto schema generation. Works like a charm now.

share|improve this answer
add comment

Your Answer

 
discard

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.