[
http://jira.jboss.com/jira/browse/JBSEAM-2418?page=all ]
Dave Sunerton-Burl updated JBSEAM-2418:
---------------------------------------
Attachment: HibernateTest.zip
I've attached a seam-gen generated project, with my additions, and NOT including the
bootstrap or lib folders and their contents. You should be able to copy over these
folders/contents and have a working project. There are a number of tests where I've
been trying to narrow down what's going wrong here...
In the HibernateTests class there are 4 tests which just select both POJO-based and
dynamic Map-based entities. They all pass. In HibernateConfigTests there's just one
test which was going to test resetting the Hibernate configuration at runtime, but
I've got stuck straight away. This test is just a copy of the
checkManagedHibernateSession() in HibernateTests - BUT IT FAILS.
So, I'm stuck. One version of the test passes, the other fails. I've done a direct
cut and paste, just in case. Until I can work out why this is happening I can't go on
to test resetting the configuration.
The HibernateSessionFactory implementation I've included will be used so that the
Hibernate configuration can be changed at runtime (adding/removing dynamic entities) but
commenting out the Seam annotations - so Seam picks up the inbuilt Hibernate
SessionFactory gives the same results.
Any hints greatly appreciated!
Cannot use non-POJO Hibernate entities with Seam-managed Session
----------------------------------------------------------------
Key: JBSEAM-2418
URL:
http://jira.jboss.com/jira/browse/JBSEAM-2418
Project: JBoss Seam
Issue Type: Bug
Affects Versions: 2.0.0.GA
Environment: WinXP, JBoss4.2
Reporter: Dave Sunerton-Burl
Attachments: HibernateTest.zip
When trying to use the Map-based mode of a Hibernate session, I get the error below.
First, here's the code that causes the error...
final Session session = (Session) Component.getInstance("dynamicSession");
final Session mapSession = session.getSession(EntityMode.MAP);
final Map record = (Map) mapSession.get("TestEntity", 10001l);
...the last line causes...
java.lang.AssertionError: java.lang.IllegalArgumentException: Not an entity class:
java.util.HashMap
at org.jboss.seam.mock.BaseSeamTest$Request.onException(BaseSeamTest.java:475)
at org.jboss.seam.mock.BaseSeamTest$Request$2.doFilter(BaseSeamTest.java:526)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:44)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:514)
at
com.fugro.traxx.entities.DynamicEntityTest.changeMappingsAtRuntime(DynamicEntityTest.java:88)
Caused by: java.lang.IllegalArgumentException: Not an entity class: java.util.HashMap
at org.jboss.seam.Entity.forClass(Entity.java:208)
at
org.jboss.seam.persistence.PersistenceProvider.getPostLoadMethod(PersistenceProvider.java:154)
at org.jboss.seam.security.Identity.checkEntityPermission(Identity.java:678)
at
org.jboss.seam.security.HibernateSecurityInterceptor.onLoad(HibernateSecurityInterceptor.java:35)
at
org.hibernate.event.def.DefaultPreLoadEventListener.onPreLoad(DefaultPreLoadEventListener.java:18)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:125)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1851)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at
org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2992)
at
org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
at
org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at
org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at
org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at
org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at
com.fugro.traxx.entities.DynamicEntityTest$3.invokeApplication(DynamicEntityTest.java:104)
at
org.jboss.seam.mock.BaseSeamTest$Request.invokeApplicationPhase(BaseSeamTest.java:652)
at org.jboss.seam.mock.BaseSeamTest$Request.emulateJsfLifecycle(BaseSeamTest.java:598)
at org.jboss.seam.mock.BaseSeamTest$Request.access$300(BaseSeamTest.java:185)
at org.jboss.seam.mock.BaseSeamTest$Request$2.doFilter(BaseSeamTest.java:519)
... 40 more
... Removed 22 stack frames
"dynamicSession" is declared in components.xml as...
<persistence:managed-hibernate-session auto-create="true"
name="dynamicSession"/>
The error seems to be connected to the HibernateSecurityInterceptor, which tries to get
hold of a real class from the mapping (which doesn't exist - this is a non-POJO
mapping). My workaround involved replacing the
"org.jboss.seam.persistence.HibernateSessionFactory" with my own implementation
which didn't add the interceptor (I will have to do without declarative security on
the dynamic entities).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira