-->
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.  [ 2 posts ] 
Author Message
 Post subject: JPA - Multiple Persistence Units w/ similar schema objects
PostPosted: Tue Aug 25, 2009 12:35 pm 
Newbie

Joined: Fri Mar 21, 2008 11:35 am
Posts: 10
So I've got one of those "I wish they didn't do it that way" types of problems.

Basically, we have 8 nearly identical systems, named a little different but for the most part all of the objects exist in each. I reverse engineered all of the objects using hibernate and annotated them w/ JPA annotations.

I am running the app on jboss 5.1. I am using the standard hibernate version for jboss 5.1, not upgraded. I compiled and built a JPA JAR file w/ each persistence unit in it, so 8 different jars. I am using an EAR file w/ each persistence unit listed individually as an ejb module, without doing this the persistence units don't get started.

I am using WebBeans + Richfaces. I have a simple form that has a drop down of 8 items to select from (matching the 8 PU's available) as well as one text box. I have a very simple JPA-QL based query, select cs from ClassSku0s cs where cs.id.sku0 = :sku This gets translated correctly to the query, and if I run the query manually, it returns results as expected. However, when I use getResultList on the query, the result set is empty.

All joins are lazy fetch, and none are required. Any ideas why hibernate cannot find results but I can?


Top
 Profile  
 
 Post subject: Re: JPA - Multiple Persistence Units w/ similar schema objects
PostPosted: Tue Aug 25, 2009 6:01 pm 
Newbie

Joined: Fri Mar 21, 2008 11:35 am
Posts: 10
So got a bit more information.

I changed my code to do something like this:

Code:
Object pk = makePK(sku0);
Object result = getByRequestType().find(getChainSku0Class(), pk);
logger.info(result);


And the result is the following stacktrace:

Code:
java.lang.IllegalArgumentException: Unknown entity: ssg.skus.coats.oe2.ChainSku0s
   at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:193)
   at org.jboss.jpa.tx.TransactionScopedEntityManager.find(TransactionScopedEntityManager.java:176)
   at ssg.stwebskudis.fa.SkuSearchResult.findSku0BySku0(Unknown Source)
   at ssg.stwebskudis.fa.SkuSearchResult.doSearch(Unknown Source)
   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:597)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
   at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)
   at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)
   at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)
   at sun.reflect.GeneratedMethodAccessor620.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)
   at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_1157840821.invoke(InvocationContextInterceptor_z_fillMethod_1157840821.java)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)
   at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_1157840821.invoke(InvocationContextInterceptor_z_setup_1157840821.java)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:60)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:81)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
   at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
   at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
   at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:176)
   at org.jboss.ejb3.session.SessionSpecContainer.invoke(SessionSpecContainer.java:216)
   at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
   at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
   at $Proxy661.doSearch(Unknown Source)
   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:597)
   at org.jboss.webbeans.util.Reflections.invokeAndWrap(Reflections.java:408)
   at org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:137)
   at ssg.stwebskudis.fa.ISkuSearchResult_$$_javassist_2793.doSearch(ISkuSearchResult_$$_javassist_2793.java)
   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:597)
   at org.jboss.webbeans.bean.proxy.ClientProxyMethodHandler.invoke(ClientProxyMethodHandler.java:97)
   at ssg.stwebskudis.fa.ISkuSearchResult_$$_javassist_2802.doSearch(ISkuSearchResult_$$_javassist_2802.java)
   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:597)
   at org.apache.el.parser.AstValue.invoke(AstValue.java:170)
   at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
   at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
   at javax.faces.component.UICommand.broadcast(UICommand.java:387)
   at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
   at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
   at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
   at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
   at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
   at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
   at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
   at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.jboss.webbeans.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:113)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
   at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
   at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
   at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.MappingException: Unknown entity: ssg.skus.coats.oe2.ChainSku0s
   at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:580)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:91)
   at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:905)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:842)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:835)
   at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:182)
   ... 116 more


Which to me seems plausible but unlikely. It looks like somehow the mappings between the multiple persistence units are throwing each other off when it comes to mapping classes with the same names. Any ideas?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.