IDEA 2017.2 hbm.xml Hibernate mappings are no longer being annotated in the editor

Answered

Is there a problem with the hibernate support in 2017.2? I've noticed that only annotated mappings listed in hibernate.cfg.xml are navigable and annotated in the editor. The older hbm.xml files listed in the same config file (both exposed via sessionfactory in spring) are no longer being shown. These used to work in 2017.1 and 2016 builds, these config files haven't changed in my project?

The hbm mapped classes are no longer showing in the persistence tool window either?

i.e. all <mapping resource="foo/bar/Entity.hbm.xml"/> in hibernate.cfg.xml are being ignored in this build?

 

0
4 comments

Please file a bug at https://youtrack.jetbrains.com/issues/IDEA and attach a small sample to reproduce.

0

Think I know whats happened when I looked at the facets I notice the spring facet is full of broken links its not been updated automatically with VCS changes. Can't remember last time I looked at the facets. Similarly the hibernate facet is missing the hibernate,cfg.xml file which must have been lost between IDEA versions somewhere. On an older branch of the code in IDEA2016 it is set.

We configure the sessionFactory with the hibernate.cfg.xml file as we have a mix of annotated classes and legacy hb,.xml ones like this:

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
p:dataSource-ref="dataSource">
<property name="hibernateProperties">
<props>
<prop key="current_session_context_class">${current.session.context.class:thread}</prop>
</props>
</property>
<property name="configLocation" value="classpath:conf/persistence/hibernate.cfg.xml"/>
</bean>

While IDEA will detect the sessionFactory bean and will add all the annotated persistent classes it seems it doesn't automatically detect the hibernate.cfg.xml passed via configLocation and doesn;t parse it. So all I see is a sessionFactory with a few of the newer beans.

But if I manually add hibernate.cfg.xml to the hibernate facet it doubles up the configuration in the persistence sidebar, but the same sessionFactory bean now shows both annotated and legacy hbm beans.

So its more to do with project settings going stale, getting messed up over probally several years and dozen of different IDEA builds?

Though I'm not sure why IDEA isn't fully parsing the sessionFactory config I can workaround it.

 

 

 

0

huh? or maybe not seems in IDEA 2017.2 at least adding the hibernate.cfg.xml to the hibernate facet isn't adding the legacy beans to the sessionFactory anymore? they do appear in the hibernate.cfg.xml element as the configuration is duplicated when you add the config manually, but it does seem there's another change in behaviour here? Something different to IDEA 2016 builds at any rate.

0

Please sign in to leave a comment.