Back Forum Reply New

Mixing annotations amp; mapping files?

hi all

all my hibernate confguration is done with the mapping files. Now I would like to test annotations. Is it possible to use both? Mapping files and annotations? If yes how do I have to configure that?If I introduce annotations in Konto.java? Can i use it in the same sessionFactory?
lt;bean id=quot;defaultSessionFactoryquot; class=quot;org..orm.hibernate3.LocalSes  sionFactoryBeanquot; singleton=quot;truequot;gt;
lt;property name=quot;dataSourcequot;gt;lt;ref bean=quot;defaultDataSourcequot;/gt;lt;/propertygt;       lt;property name=quot;mappingResourcesquot;gt;lt;listgt;
lt;valuegt;Address.hbm.xmllt;/valuegt;
lt;valuegt;Herkunft.hbm.xmllt;/valuegt;
lt;valuegt;Information.hbm.xmllt;/valuegt;
lt;valuegt;Konto.hbm.xmllt;/valuegt;
.........
lt;/listgt;       lt;/propertygt;       lt;property name=quot;hibernatePropertiesquot;gt;       lt;propsgt;lt;prop key=quot;hibernate.dialectquot;gt;org.hibernate.dialect.Orac  le9Dialectlt;/propgt;lt;prop key=quot;hibernate.show_sqlquot;gt;truelt;/propgt;lt;prop key=quot;hibernate.max_fetch_depthquot;gt;10lt;/propgt;       lt;/propsgt;       lt;/propertygt;   lt;/beangt;

Kind Regards
Angela

problem solved!lt;beansgt;   lt;!-- Hibernate Default SessionFactory --gt;   lt;bean id=quot;defaultSessionFactoryquot; class=quot;org..orm.hibernate3.annotati  on.AnnotationSessionFactoryBeanquot; singleton=quot;truequot;gt;
lt;property name=quot;dataSourcequot;gt;lt;ref bean=quot;defaultDataSourcequot;/gt;lt;/propertygt;       lt;property name=quot;mappingResourcesquot;gt;lt;listgt;
lt;!-- lt;valuegt;Aktion.hbm.xmllt;/valuegt;  --gt;
lt;valuegt;Transaktion.hbm.xmllt;/valuegt;
lt;valuegt;Taetigkeit.hbm.xmllt;/valuegt;
lt;valuegt;Berechtigung.hbm.xmllt;/valuegt;
lt;valuegt;BenutzerProfilMapping.hbm.xmllt;/valuegt;
lt;valuegtrofilTaetigkeitMapping.hbm.xmllt;/valuegt;
lt;valuegt;TransaktionAktionMapping.hbm.xmllt;/valuegt;
lt;/listgt;       lt;/propertygt;        lt;property name=quot;annotatedClassesquot;gt;    lt;listgt;      lt;valuegt;najsre7.model.Aktionlt;/valuegt;    lt;/listgt;  lt;/propertygt;       lt;property name=quot;hibernatePropertiesquot;gt;       lt;propsgt;lt;prop key=quot;hibernate.dialectquot;gt;org.hibernate.dialect.Orac  le9Dialectlt;/propgt;lt;prop key=quot;hibernate.show_sqlquot;gt;truelt;/propgt;lt;prop key=quot;hibernate.max_fetch_depthquot;gt;10lt;/propgt;       lt;/propsgt;       lt;/propertygt;   lt;/beangt;

Hi,

I must mix hbm mapping files with annotated classes. I use the same configuration as mentioned above:Code:
lt;!-- Hibernate Default SessionFactory --gt;
lt;bean id=quot;hbnSessionFactoryquot; class=quot;org..orm.hibernate3.annotation.AnnotationSessionFactoryBeanquot;gt;
lt;property name=quot;dataSourcequot; ref=quot;dataSourcequot;/gt;
lt;property name=quot;mappingResourcesquot;gt;
lt;listgt;
lt;!-- JBPM Tables --gt;
lt;!-- hql queries and type defs --gt;
lt;valuegt;org/jbpm/graph/action/MailAction.hbm.xmllt;/valuegt;
....
lt;/listgt;
lt;/propertygt;
lt;property name=quot;annotatedClassesquot;gt;
lt;listgt;
lt;valuegt;mypackage.MyClasslt;/valuegt;
lt;/listgt;
lt;/propertygt;
lt;property name=quot;hibernatePropertiesquot;gt;
lt;propsgt;
lt;prop key=quot;hibernate.dialectquot;gt;${database.dialect}lt;/propgt;
lt;prop key=quot;hibernate.show_sqlquot;gt;truelt;/propgt;
lt;prop key=quot;hibernate.max_fetch_depthquot;gt;10lt;/propgt;
lt;prop key=quot;hibernate.hbm2ddl.autoquot;gt;updatelt;/propgt;
lt;/propsgt;
lt;/propertygt;
lt;/beangt;
I get the following exception:

Code:
org..beans.factory.BeanCreationException: Error creating bean with name 'hbnSessionFactory' defined in class path resource [test-genericDao-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalAccessError: tried to access field org.hibernate.cfg.Configuration.xmlHelper from class org.hibernate.cfg.AnnotationConfiguration
Caused by: java.lang.IllegalAccessError: tried to access field org.hibernate.cfg.Configuration.xmlHelper from class org.hibernate.cfg.AnnotationConfiguration
at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:556)
at org..orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:656)
at org..orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
at org..beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
at org..beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org..beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org..beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284)
at org..context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org..test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:199)
at org..test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:179)
at org..test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:158)
at org..test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:105)
at org..test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:87)
at junit.framework.TestCase.runBare(TestCase.java:125)
at org..test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Any hints?
thanks for your help

Is there anybody out there with any hints?

thanks

You should use proper hibernate version. I've got this problem in 3.1.3 (hibernate) 3.3.0 (annotation) and moved to 3.2.5.ga (hibernate), and everything is fine.

are you able to solved this problem. i am using hibernate 3.2.7.ga ,but still get the above error  like user quot;demoquot;
¥
Back Forum Reply New