Question

I have an web application in Grails, that is running pretty well. But I have a problem that two other jars projects I need to embed in my application have hibernate programatically configuration.

The problem is that embedding this jars my web app is getting the entities of the jar's and updating their schema in the database, and the other and higher problem is that the jar's couldn't instantiating the entities, because they are giving me a " org.hibernate.MappingException: Unknown entity: ..."

Anyone had this problem yet? What is the good solution in this case?

Was it helpful?

Solution

You can pass additional entities to grails hibernate configuration using grails-app/conf/hibernate/hibernate.cfg.xml file.

That's treated as a regular hibernate config.

 <mapping package="com.example" />
 <mapping class="com.example.dao.model.Address" />

will add com.example.dao.model.Address to grails known entities

OTHER TIPS

You can exclude transitive dependencies from your dependencies. Either you can specify not to pull in all transitive dependencies or specifically can exclude the dependency you don't need.

//BuildConfig.groovy
dependencies {
    compile('com.example.app1:1.0') {
        transitive = false
    }

    //or
    compile('com.example.app1:1.0') {
        excludes "hibernate", "something-else"
    }
}

Refer Grails Configurations for details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top