[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2212) getter (for many-to-one) did not work with an interface as return values

Manfred Quasten (JIRA) noreply at atlassian.com
Sun Nov 5 12:49:04 EST 2006


getter (for many-to-one)  did not work with an interface as return values
-------------------------------------------------------------------------

         Key: HHH-2212
         URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2212
     Project: Hibernate3
        Type: Improvement

 Environment: java 5.0, eclipse jboss ide, oracle 9i on xp , classes12.jar jdbc diver
    Reporter: Manfred Quasten
 Attachments: Configuration.jdo.xml, Document.java, DocumentConfiguration.java

the getter Method for a many-to-one Method can not have an Interface as returntype :

( ConfigurationImpl  implements the interface DocumentConfiguration )

The first opportunity works, the second one not :

... 
public ConfigurationImpl getConfiguration() {
           return  (ConfigurationImpl) configuration;
}

...
public DocumentConfiguration getConfiguration() {
           return   configuration;
}



This is bad, because it is not possible to work against an interface and to change the implementation (testmocks etc )  (using dependency injection for example)
I think the real returned type should be taken for the mapping  not the signature of  the method. If the signature of the method is an interface that it implemented by the returned class it should work too . 


The error message for the second case :

Exception in thread "main" org.hibernate.MappingException: An association from the table xDocument refers to an unmapped class: de.mq.fourier.server.document.DocumentConfiguration
	at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1134)
	at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1052)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1168)
	at de.mq.fourier.server.document.dao.ConfigurationHibernateDAO.<init>(ConfigurationHibernateDAO.java:18)
	at de.mq.fourier.server.document.dao.ConfigurationHibernateDAO.main(ConfigurationHibernateDAO.java:73)




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list