Hi All,
I'm getting a classcastexception at the entity manager factory bootstrap when i set some config overrides.
I did a debug and found that PersistenceXmlLoader.deploy retreive the keySet of the overrides map and cast it to a Set<Map.Entry>, so i'm guessing a entrySet() would be more suitable.
I think it's a bug and should be posted on jira but i'm not sure i'm not doing something wrong.
Can you tell me if it is the case ?
This is the code that throw the exception :
for ( Map.Entry entry : (Set<Map.Entry>) overrides.keySet() ) {
...
}
Thanks in advance
Cyril.
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Hibernate 3.2CR1
Hibernate EntityManager 3.1-beta7
Hibernate Annotations 3.2-beta9
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd"
version="1.0">
<persistence-unit name="dapc" transaction-type="RESOURCE_LOCAL">
<class>fr.uma.dapc.model.Critere</class>
<class>fr.uma.dapc.model.Civilite</class>
<class>fr.uma.dapc.model.Marque</class>
<class>fr.uma.dapc.model.Tva</class>
<class>fr.uma.dapc.model.Internaute</class>
<class>fr.uma.dapc.model.Contact</class>
<class>fr.uma.dapc.model.Prestation</class>
<class>fr.uma.dapc.model.PrestationSousSalon</class>
<class>fr.uma.dapc.model.Exposant</class>
<class>fr.uma.dapc.model.ExposantLie</class>
<class>fr.uma.dapc.model.TarifEvolutif</class>
<class>fr.uma.dapc.model.Stand</class>
<class>fr.uma.dapc.model.ModeleDa</class>
<class>fr.uma.dapc.model.Commande</class>
<class>fr.uma.dapc.model.SousSalon</class>
<class>fr.uma.dapc.model.Traduction</class>
<class>fr.uma.dapc.model.traductions.TraductionCritere</class>
<class>fr.uma.dapc.model.traductions.TraductionCivilite</class>
<class>fr.uma.dapc.model.traductions.TraductionCivilitePostale</class>
<class>fr.uma.dapc.model.traductions.TraductionConferenceLibelle</class>
<class>fr.uma.dapc.model.traductions.TraductionConferenceTheme</class>
<class>fr.uma.dapc.model.traductions.TraductionModeleDa</class>
<class>fr.uma.dapc.model.traductions.TraductionModeleStand</class>
<class>fr.uma.dapc.model.traductions.TraductionPaiementFractionne</class>
<class>fr.uma.dapc.model.traductions.TraductionPrestation</class>
<class>fr.uma.dapc.model.traductions.TraductionTableDeParametrage</class>
<class>fr.uma.dapc.model.Session</class>
<class>fr.uma.dapc.model.RubriqueFacturation</class>
<class>fr.uma.dapc.model.ModeleStand</class>
<class>fr.uma.dapc.model.PaiementFractionne</class>
<class>fr.uma.dapc.model.Conference</class>
<class>fr.uma.dapc.model.TableDeParametrage</class>
<class>fr.uma.dapc.model.CoordonneesComplementaires</class>
<class>fr.uma.dapc.model.MessageRessources</class>
<properties>
<property name="hibernate.connection.url" value="jdbc:hsqldb:." />
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
<property name="hibernate.connection.username" value="sa" />
<property name="hibernate.connection.password" value="" />
<property name="hibernate.showsql" value="true" />
<property name="hibernate.jdbc.use_streams_for_binary" value="true" />
<property name="hibernate.jdbc.batch_size" value="0" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
</properties>
</persistence-unit>
</persistence>
Code between sessionFactory.openSession() and session.close():
Map configOverrides = new HashMap();
configOverrides.put("hibernate.hbm2ddl.auto", "create-drop");
emFactory = Persistence.createEntityManagerFactory("dapc", configOverrides);
Full stack trace of any exception that occurs:
javax.persistence.PersistenceException: java.lang.ClassCastException: java.lang.String
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:110)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
at fr.uma.dapc.dao.TestLazyEM.setUp(TestLazyEM.java:31)
at junit.framework.TestCase.runBare(TestCase.java:125)
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.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassCastException: java.lang.String
at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:101)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:150)
... 13 more
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: