[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-6943) hbm with xsd is not working

nick (JIRA) noreply at atlassian.com
Sun Jan 8 05:07:10 EST 2012


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45007#comment-45007 ] 

nick commented on HHH-6943:
---------------------------

Hi Steve, appreciate your immediate response.

I can wait for Hibernate 5.0 but let me explain you few things. 

I'm attaching my cfg file  and one more hbm file.

We were using the following configuration to build sessionfactory

final Configuration configuration = new Configuration();
resolveAndConfigureMappingJars(configuration); // Here we are adding jar files containing only hbm files.
resolveAndConfigureAnnotedClass(configuration);// Here we are adding hibernate annotted class.
configuration.setProperty(AvailableSettings.DATASOURCE, "java:/MyDS");
configuration.configure();
SessionFactory sessionFactory = configuration.buildSessionFactory();

With this configuration i can able create SessionFactory and a work with that. But very lately we found that  our custom EventListner which configured in cfg file (attached) is not getting invoked.

This made us to use new way of building hibernate SessionFactory as below

ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder();
serviceRegistryBuilder.applySetting(AvailableSettings.DATASOURCE,  "java:/MyDS");
serviceRegistryBuilder.configure(ServiceRegistryBuilder.DEFAULT_CFG_RESOURCE_NAME);
MetadataSources metadataSources = new MetadataSources(serviceRegistryBuilder.buildServiceRegistry());
resolveAndConfigureMappingJars(metadataSources);
resolveAndConfigureAnnotedClass(metadataSources);
SessionFactory sessionFactory= metadataSources.buildMetadata().buildSessionFactory();  

When we use this we have faced 4 major issues and finally a critical bug stopped it from using for ever.

Bug 
1) MetadataSources#addJar is 200% or more slower that the earlier Configuration#addJar
2) cfg DTD is not picking up
3) hbm DTD is not picking up

I solved the first and second bug by using the following XSD respectively in cfg and hbm files

<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
						 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
				         xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd">

<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
				   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
				   xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping hibernate-mapping-4.0.xsd">

After this change i got the Bug which is filed here HHH-6943 ie

4) column tag is not working without adding not-null and unique attribute in it.

I solved the above bug by adding  not-null and unique attribute in column tag in all my hbm's.

I thought everything will works fine from here but i got the BLOCKER bug after that as follows.

..........................................................................................................

02:10:50,048 ERROR [org.hibernate.AssertionFailure] (http-srikanth-laptop-127.0.0.1-8080-1) HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: Collection table not yet bound
02:10:54,365 ERROR [org.egov.infstr.client.filter.HibSessionServletFilter] (http-srikanth-laptop-127.0.0.1-8080-1) org.hibernate.AssertionFailure: Collection table not yet bound
02:10:54,370 ERROR [org.egov.EGOVRuntimeException] (http-srikanth-laptop-127.0.0.1-8080-1) Collection table not yet bound: org.hibernate.AssertionFailure: Collection table not yet bound
	at org.hibernate.metamodel.binding.CollectionKey.prepareForeignKey(CollectionKey.java:59) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.source.binder.Binder.bindCollectionKey(Binder.java:623) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.source.binder.Binder.bindPersistentCollection(Binder.java:492) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.source.binder.Binder.bindAttributes(Binder.java:426) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.source.binder.Binder.doCreateEntityBinding(Binder.java:150) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.source.binder.Binder.createEntityBinding(Binder.java:132) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.source.binder.Binder.processEntityHierarchy(Binder.java:108) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.source.hbm.HbmMetadataSourceProcessorImpl.processMappingMetadata(HbmMetadataSourceProcessorImpl.java:88) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.source.internal.MetadataImpl.bindMappingMetadata(MetadataImpl.java:195) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.source.internal.MetadataImpl.<init>(MetadataImpl.java:165) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.source.internal.MetadataBuilderImpl.buildMetadata(MetadataBuilderImpl.java:83) [hibernate-core-4.0.0.Final.jar:]
	at org.hibernate.metamodel.MetadataSources.buildMetadata(MetadataSources.java:112) [hibernate-core-4.0.0.Final.jar:]
	at org.egov.infstr.utils.HibernateUtil.createSessionFactory(HibernateUtil.java:78) [egov-infrastructure.jar:]
	at org.egov.infstr.utils.HibernateUtil.getSessionFactory(HibernateUtil.java:143) [egov-infrastructure.jar:]
	at org.egov.infstr.utils.HibernateUtil.getCurrentSession(HibernateUtil.java:150) [egov-infrastructure.jar:]
	at org.egov.infstr.utils.HibernateUtil.beginTransaction(HibernateUtil.java:163) [egov-infrastructure.jar:]
	at org.egov.infstr.client.filter.HibSessionServletFilter.doFilter(HibSessionServletFilter.java:54) [egov-infrastructure.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.6.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.6.Final.jar:]
	at org.egov.infstr.client.filter.SetThreadLocals.doFilter(SetThreadLocals.java:49) [egov-infrastructure.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.6.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.6.Final.jar:]
	at net.sf.ehcache.constructs.web.filter.GzipFilter.doFilter(GzipFilter.java:85) [ehcache-web-2.0.3.jar:]
	at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86) [ehcache-web-2.0.3.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.6.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.6.Final.jar:]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [org.springframework.web-3.1.0.RELEASE.jar:]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) [org.springframework.web-3.1.0.RELEASE.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.6.Final.jar:]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.6.Final.jar:]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.6.Final.jar:]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.6.Final.jar:]
	at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151) [jboss-as-web-7.1.0.CR1-SNAPSHOT.jar:]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.6.Final.jar:]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.6.Final.jar:]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.6.Final.jar:]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.6.Final.jar:]
	at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.6.Final.jar:]
	at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.6.Final.jar:]
	at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033) [jbossweb-7.0.6.Final.jar:]
	at java.lang.Thread.run(Thread.java:619) [:1.6.0]

............................................................................................................


Precisely there is lot of Bugs using MetadataSource configuration. Since you said you were focusing it for Hibernate 5.0, i don't know how long i have to wait for it. So here i can use the old way of configuring SessionFactory but i need to know why custom EventListner is not getting invoked, where it was perfectly working with Hibernate 3.


I guess EventListner's are not getting configured from cfg file is a BUG....... If you want i can file it as a separate bug...


Please give us an immediate reply since we completely stuck with Hibernate 4 Migration for our Major release.








> hbm with xsd is not working
> ---------------------------
>
>                 Key: HHH-6943
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6943
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core, metamodel
>    Affects Versions: 4.0.0.Final
>         Environment: Hibernate 4.0.0 Final + JBoss AS 7 + PostgreSQL
>            Reporter: nick
>             Fix For: 5.0.0
>
>         Attachments: Accountdetailkey.hbm.xml, hibernate.cfg.xml
>
>
> While using any of the following xsd in hbm.xml 
> <hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
> 				   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 				   xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd">
> Or
> <hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
> 				   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 				   xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping hibernate-mapping-4.0.xsd">
> or
> <hh:hibernate-mapping xmlns:hh="http://www.hibernate.org/xsd/hibernate-mapping"
> 				   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 				   xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping hibernate-mapping-4.0.xsd">
> Its throwing the following error
> Caused by: java.lang.NullPointerException
> 	at org.hibernate.metamodel.source.hbm.ColumnSourceImpl.isUnique(ColumnSourceImpl.java:109) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.binder.Binder.makeColumn(Binder.java:1091) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.binder.Binder.bindRelationalValues(Binder.java:1023) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.binder.Binder.doBasicSingularAttributeBindingCreation(Binder.java:747) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.binder.Binder.bindSimpleIdentifier(Binder.java:331) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.binder.Binder.bindIdentifier(Binder.java:314) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.binder.Binder.makeRootEntityBinding(Binder.java:183) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.binder.Binder.createBasicEntityBinding(Binder.java:159) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.binder.Binder.doCreateEntityBinding(Binder.java:147) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.binder.Binder.createEntityBinding(Binder.java:132) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.binder.Binder.processEntityHierarchy(Binder.java:108) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.hbm.HbmMetadataSourceProcessorImpl.processMappingMetadata(HbmMetadataSourceProcessorImpl.java:88) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.internal.MetadataImpl.bindMappingMetadata(MetadataImpl.java:195) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.internal.MetadataImpl.<init>(MetadataImpl.java:165) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.source.internal.MetadataBuilderImpl.buildMetadata(MetadataBuilderImpl.java:83) [hibernate-core-4.0.0.Final.jar:]
> 	at org.hibernate.metamodel.MetadataSources.buildMetadata(MetadataSources.java:112) [hibernate-core-4.0.0.Final.jar:]
> I'm attaching one of my hbm file which creating this error.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list