I'm trying to override an entity configured w/ annotations with an external xml file. I'm manually creating the Factory in HibernateUtil, but I've also tried adding it to the hibernate.cfg.xml, and get the following error:
Code:
Exception in thread "main" 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 hibernate.HibernateUtil.makeOverriddenFactory(HibernateUtil.java:112)
at golf.speed.NewHierarchy.doWork(NewHierarchy.java:21)
at golf.speed.NewHierarchy.main(NewHierarchy.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Here's is the code to create the factory
Code:
AnnotationConfiguration conf = new AnnotationConfiguration();
File confFile = new File(GlobalProperties.getProperty("hibernate_config"));
conf.configure(confFile);
conf.addAnnotatedClass(MapData.class);
conf.addFile(new File("c:/dave/weatherbonk/annotOverride.xml"));
and the annotOverride.xml is
Code:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
version="1.0">
<package>weathermaps.weather.points</package>
<entity class="MapData">
<inheritance strategy="TABLE_PER_CLASS"/>
</entity>
</entity-mappings>
I'm using annotations 3.2CR1 and hibernate 3.1.3 with mysql 5.0
I'm trying to follow
http://www.hibernate.org/hib_docs/annot ... overriding
but it doesn't show how to integrate this file to the configuration.
Is there another method to use to add this configuration override to the AnnotationConfiguration object.
Any help is greatly appreciated