Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HibernateDomainExporter does not register spatial types #2320

ridoo opened this issue Jun 18, 2018 · 3 comments · Fixed by #2713

HibernateDomainExporter does not register spatial types #2320

ridoo opened this issue Jun 18, 2018 · 3 comments · Fixed by #2713


Copy link

ridoo commented Jun 18, 2018


Is it possible to either

  • configure the Maven plugin generating code from a set of hbm.xml files
  • configure the JPADomainExporter to register spatial types

I use version 4.1.3.


Section 2.1.4. Generating the model from hbm.xml files describes a way to generate code from XML mapping files. Having a simple Spring Boot Application:

public class Application implements CommandLineRunner {

    public static void main(String[] args) {, args);

    private EntityManagerFactory entityManagerFactory;

    public SessionFactory sessionFactory() {
        if (entityManagerFactory.unwrap(SessionFactory.class) == null) {
            throw new NullPointerException("factory is not a hibernate factory");
        return entityManagerFactory.unwrap(SessionFactory.class);

    public EntityManagerFactory entityManagerFactory(DataSource datasource, JpaProperties properties)
            throws IOException {
        LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
        emf.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
        return emf.getNativeEntityManagerFactory();

    public void run(String... args) throws Exception {

    private JPADomainExporter createExporter(String prefix) {
        final Metamodel metamodel = entityManagerFactory.getMetamodel();
        return new JPADomainExporter(prefix, new File("src/main/java"), metamodel);


I first tried to use HibernateDomainExporter but the above config also worked out for JPADomainExporter. The mapping files are declared within a META-INF/persistence.xml on the classpath, like so:

<persistence xmlns=""
    <persistence-unit name="default-unit">
        <description>Default Mappings</description>

        <!-- et cetera --> 


This works rather well. However, I do have spatial types which are not mapped by default. The documentation hints me to add <spatial>true</spatial> to the Maven plugin config, but I did not find a way to configure the maven codegen plugin to work with hbm.xml mappings.

Copy link
Contributor Author

ridoo commented Jun 18, 2018

I opened a PR which makes it possible to register spatial paths in a non-Maven run.

Copy link

I saw it, thanks, first glance looks good!
Yes if you want it to be used in Querydsl 4, then keeping the old class is needed.

ridoo added a commit to 52North/sensorweb-server-db-model that referenced this issue Jun 18, 2018
This includes a (hopefully) temporary workaround how querydsl
registers spatial path types, i.e. customized versions of

  - AbstractDomainExporter

  - JPADomainExporter

  - SpatialSupport

are used to register needed types. There is a PR open which
discusses the enablement registering such paths from non-apt
use cases.

  - querydsl/querydsl#2320
  - querydsl/querydsl#2322
Copy link
Contributor Author

ridoo commented Jun 19, 2018

I've restored the old SpatialSupport now delegating to SpatialTypeMapper which encapsulates the actual type registration. I shamelessly marked SpatialSupport as @Deprecated, so feel free to revert if you have reasons to not doing so. I am not aware if you have any rules when to deprecate something or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
No open projects
Awaiting triage
3 participants