-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: PersistenceException on properties override
PostPosted: Tue Mar 28, 2006 4:32 am 
Newbie

Joined: Tue Mar 28, 2006 4:20 am
Posts: 1
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:


Top
 Profile  
 
 Post subject: Got the same problem
PostPosted: Wed Mar 29, 2006 5:28 am 
Newbie

Joined: Fri Sep 03, 2004 10:53 am
Posts: 7
I have the same problem as PataDepartie. The offending line is:
for ( Map.Entry entry : (Set<Map.Entry>) overrides.keySet() ) {
and as Pata says, the code should be:
for ( Map.Entry entry : (Set<Map.Entry>) overrides.entrySet() ) {


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 4:27 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Yes I let this bug slip, sorry.
This is fixed in SVN head, in the meanwhile, use the fix proposed by jonathan

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.