Hello Marc,

You stated: "Please note that referencedColumnName value is not the primary 
key. "

Accorging to the Manual (13.8.4) - the referencedColumnName is 
"The name of the primary key column being joined to.  If there is only one 
identity
field in the related entity class, the join column name defaults to the name of 
the
identity field's column."

Regards,

 

John

---- 

Who is General Failure, and why is he reading my hard disk?








> -----Ursprüngliche Nachricht-----
> Von: Marc Logemann [mailto:l...@logemann.org] 
> Gesendet: Donnerstag, 22. Dezember 2011 17:55
> An: users@openjpa.apache.org
> Betreff: Re: org.apache.openjpa.util.LongId cannot be cast to 
> MyDomainObject
> 
> Hi,
> 
> The customer has the same database, the same application 
> (same build and stuff like that) and same everything. This is 
> what freaks me out ;-) Of course something must be different...
> I compared the schema several times and they are the same.
> 
> Turning on Trace is quite impossible on a production machine. 
> I would rather do a DB migration and use the primary key 
> "oid"  as foreign key constraint instead of some random string field.
> 
> Perhaps i can get my hands on another machine which is not 
> production and also results in that error. Then i could do 
> remote debugging. But even with remote debugging turned on, 
> its not likely that i fully understand whats wrong.
> 
> ---
> regards
> Marc Logemann
> http://www.logemann.org
> http://www.logentis.de
> 
> 
> 
> 
> Am 22.12.2011 um 17:00 schrieb Kevin Sutter:
> 
> > Hi Marc,
> > I'm not seeing anything wrong with your object model 
> definition.  But, 
> > it definitely looks like OpenJPA is getting confused on this join 
> > column reference (string id) and the type of the primary 
> key (long).  
> > Have you been able to verify that the database schemas are 
> consistent 
> > with the object model?  Does your customer and your development 
> > system(s) use the same database type (ie. mysql)?  I really 
> don't think it's a data issue.
> > It looks more like a data-definition issue either in the 
> object model 
> > or the database itself.
> > 
> > How about your persistence unit definition?  Does the customer 
> > environment and your development environment use the same 
> > persistence.xml?  For example, do you dynamically sync the database 
> > schema with the object model, or do you pre-create the 
> database schema via ddl?
> > 
> > I'd start with turning on Trace and comparing the flows to 
> see where 
> > there are differences.
> > 
> > BTW, I totally agree with your comment that OpenJPA is too 
> complex to 
> > comprehend in just a few hours...  :-)
> > 
> > Good luck,
> > Kevin
> > 
> > On Wed, Dec 21, 2011 at 5:21 PM, Marc Logemann 
> <l...@logemann.org> wrote:
> > 
> >> Hi,
> >> 
> >> me again. This time with something i also dont get.
> >> 
> >> OrderPosition.class
> >> ---------------------------
> >>   @XmlTransient
> >>   @ManyToOne
> >>   @JoinColumn(name = "con_ship_id", referencedColumnName = "id")
> >>   ContainerShipment containerShipment;
> >> 
> >> ContainerShipment.class
> >> -----------------------------------
> >>   @XmlTransient
> >>   @Id
> >>   @GeneratedValue(strategy = GenerationType.TABLE, generator =
> >> "contShipGen")
> >>   @TableGenerator(name = "contShipGen", table = "jpa_sequence", 
> >> pkColumnName = "ID",
> >>           pkColumnValue = "ContainerShipment", valueColumnName = 
> >> "SEQUENCE_VALUE", initialValue = 2000, allocationSize = 2)
> >>   long oid;
> >> 
> >>   @Column(name = "id")
> >>   String id;
> >> 
> >>   @OneToMany(mappedBy = "containerShipment", cascade = 
> >> CascadeType.ALL, fetch = FetchType.EAGER)
> >>   List<OrderPosition> orderPositions;
> >> 
> >> 
> >> Please note that referencedColumnName value is not the 
> primary key. 
> >> Its just a simple String/varchar field.
> >> 
> >> Following Stack produced. Even more scary. This stack 
> doesnt appear 
> >> on my developer machine with test DB, but on customer machine with 
> >> different dataset. So it looks data related but i cant be for sure 
> >> because i have not seen any data problems in the DB.
> >> Thanks again for hints. It seems that inside TransferFieldManager, 
> >> there is a LongId on field index = 12 instead of a 
> ContainerShipment. 
> >> But i dont know why its there. As i said, i cant say for 
> sure because 
> >> on my development machine everything is fine which makes 
> debugging a 
> >> little bit hard. Its also not that easy to fully understand the 
> >> OpenJPA code. Its just too complex to analyze in a few hours.
> >> 
> >> 
> >> 
> >> <openjpa-2.1.1-r422266:1148538 nonfatal general error>
> >> org.apache.openjpa.persistence.PersistenceException:
> >> org.apache.openjpa.util.LongId cannot be cast to 
> >> de.logentis.bwh.model.ContainerShipment
> >> FailedObject: SELECT cs FROM ContainerShipment cs 
> [java.lang.String]
> >>       at 
> org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:1008)
> >>       at 
> org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:907)
> >>       at
> >> 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStore
> Manager.java:1041)
> >>       at
> >> 
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult
> .java:280)
> >>       at
> >> 
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(Selec
> tImpl.java:2381)
> >>       at
> >> 
> org.apache.openjpa.jdbc.meta.strats.RelationToManyInverseKeyFi
> eldStrategy.loadElement(RelationToManyInverseKeyFieldStrategy.java:90)
> >>       at
> >> 
> org.apache.openjpa.jdbc.meta.strats.RelationCollectionInverseK
> eyFieldStrategy.loadElement(RelationCollectionInverseKeyFieldS
> trategy.java:76)
> >>       at
> >> 
> org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrate
> gy.processEagerParallelResult(StoreCollectionFieldStrategy.java:312)
> >>       at
> >> 
> org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrate
> gy.loadEagerParallel(StoreCollectionFieldStrategy.java:246)
> >>       at
> >> 
> org.apache.openjpa.jdbc.meta.FieldMapping.loadEagerParallel(Fi
> eldMapping.java:916)
> >>       at
> >> 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStore
> Manager.java:1114)
> >>       at
> >> 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStore
> Manager.java:1067)
> >>       at
> >> 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeStat
> e(JDBCStoreManager.java:438)
> >>       at
> >> 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDB
> CStoreManager.java:333)
> >>       at
> >> 
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(De
> legatingStoreManager.java:112)
> >>       at
> >> 
> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreM
> anager.java:57)
> >>       at
> >> 
> org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1027)
> >>       at 
> org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:985)
> >>       at 
> org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:907)
> >>       at
> >> 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStore
> Manager.java:1041)
> >>       at
> >> 
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult
> .java:280)
> >>       at
> >> 
> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(Selec
> tImpl.java:2381)
> >>       at
> >> 
> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult
> .java:274)
> >>       at
> >> 
> org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.ge
> tResultObject(InstanceResultObjectProvider.java:59)
> >>       at
> >> 
> org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultL
> ist.java:36)
> >>       at 
> org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1251)
> >>       at 
> org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1007)
> >>       at 
> org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
> >>       at 
> org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
> >>       at
> >> 
> org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQu
> ery.java:542)
> >>       at
> >> 
> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:315)
> >>       at
> >> 
> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryIm
> pl.java:331)
> >>       at
> >> 
> de.netstorsys.dao.repositories.ContainerShipmentRepositoryImpl
> .findAllCustom(ContainerShipmentRepositoryImpl.java:39)
> >>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>       at
> >> 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccess
> orImpl.java:39)
> >>       at
> >> 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMeth
> odAccessorImpl.java:25)
> >>       at java.lang.reflect.Method.invoke(Method.java:597)
> >>       at
> >> 
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingR
> eflection(AopUtils.java:311)
> >>       at
> >> 
> org.springframework.aop.framework.ReflectiveMethodInvocation.i
> nvokeJoinpoint(ReflectiveMethodInvocation.java:183)
> >>       at
> >> 
> org.springframework.aop.framework.ReflectiveMethodInvocation.p
> roceed(ReflectiveMethodInvocation.java:150)
> >>       at
> >> 
> org.springframework.transaction.interceptor.TransactionInterce
> ptor.invoke(TransactionInterceptor.java:110)
> >>       at
> >> 
> org.springframework.aop.framework.ReflectiveMethodInvocation.p
> roceed(ReflectiveMethodInvocation.java:172)
> >>       at
> >> 
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(Jd
> kDynamicAopProxy.java:202)
> >>       at $Proxy903.findAllCustom(Unknown Source)
> >>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>       at
> >> 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccess
> orImpl.java:39)
> >>       at
> >> 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMeth
> odAccessorImpl.java:25)
> >>       at java.lang.reflect.Method.invoke(Method.java:597)
> >>       at
> >> 
> org.springframework.data.repository.core.support.RepositoryFac
> torySupport$QueryExecutorMethodInterceptor.executeMethodOn(Rep
> ositoryFactorySupport.java:368)
> >>       at
> >> 
> org.springframework.data.repository.core.support.RepositoryFac
> torySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFa
> ctorySupport.java:338)
> >>       at
> >> 
> org.springframework.aop.framework.ReflectiveMethodInvocation.p
> roceed(ReflectiveMethodInvocation.java:172)
> >>       at
> >> 
> org.springframework.transaction.interceptor.TransactionInterce
> ptor.invoke(TransactionInterceptor.java:110)
> >>       at
> >> 
> org.springframework.aop.framework.ReflectiveMethodInvocation.p
> roceed(ReflectiveMethodInvocation.java:172)
> >>       at
> >> 
> org.springframework.dao.support.PersistenceExceptionTranslatio
> nInterceptor.invoke(PersistenceExceptionTranslationInterceptor
> .java:155)
> >>       at
> >> 
> org.springframework.aop.framework.ReflectiveMethodInvocation.p
> roceed(ReflectiveMethodInvocation.java:172)
> >>       at
> >> 
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(Jd
> kDynamicAopProxy.java:202)
> >>       at $Proxy904.findAllCustom(Unknown Source)
> >>       at
> >> 
> de.netstorsys.controller.rest.ContainerShipmentRestController.
> showAll(ContainerShipmentRestController.java:53)
> >>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>       at
> >> 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccess
> orImpl.java:39)
> >>       at
> >> 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMeth
> odAccessorImpl.java:25)
> >>       at java.lang.reflect.Method.invoke(Method.java:597)
> >>       at
> >> 
> org.springframework.web.bind.annotation.support.HandlerMethodI
> nvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
> >>       at
> >> 
> org.springframework.web.servlet.mvc.annotation.AnnotationMetho
> dHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAda
> pter.java:426)
> >>       at
> >> 
> org.springframework.web.servlet.mvc.annotation.AnnotationMetho
> dHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
> >>       at
> >> 
> org.springframework.web.servlet.DispatcherServlet.doDispatch(D
> ispatcherServlet.java:790)
> >>       at
> >> 
> org.springframework.web.servlet.DispatcherServlet.doService(Di
> spatcherServlet.java:719)
> >>       at
> >> 
> org.springframework.web.servlet.FrameworkServlet.processReques
> t(FrameworkServlet.java:644)
> >>       at
> >> 
> org.springframework.web.servlet.FrameworkServlet.doGet(Framewo
> rkServlet.java:549)
> >>       at 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
> >>       at 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> >>       at
> >> 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilt
> er(ApplicationFilterChain.java:290)
> >>       at
> >> 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(Appli
> cationFilterChain.java:206)
> >>       at
> >> 
> org.springframework.web.filter.CharacterEncodingFilter.doFilte
> rInternal(CharacterEncodingFilter.java:88)
> >>       at
> >> 
> org.springframework.web.filter.OncePerRequestFilter.doFilter(O
> ncePerRequestFilter.java:76)
> >>       at
> >> 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilt
> er(ApplicationFilterChain.java:235)
> >>       at
> >> 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(Appli
> cationFilterChain.java:206)
> >>       at
> >> 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardW
> rapperValve.java:233)
> >>       at
> >> 
> org.apache.catalina.core.StandardContextValve.invoke(StandardC
> ontextValve.java:191)
> >>       at
> >> 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHost
> Valve.java:127)
> >>       at
> >> 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReport
> Valve.java:102)
> >>       at
> >> 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEn
> gineValve.java:109)
> >>       at
> >> 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdap
> ter.java:293)
> >>       at
> >> 
> org.apache.coyote.http11.Http11Processor.process(Http11Process
> or.java:859)
> >>       at
> >> 
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandle
> r.process(Http11Protocol.java:602)
> >>       at
> >> 
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.
> java:489)
> >>       at java.lang.Thread.run(Thread.java:680)
> >> Caused by: java.lang.ClassCastException: 
> >> org.apache.openjpa.util.LongId cannot be cast to 
> de.logentis.bwh.model.ContainerShipment
> >>       at
> >> 
> de.logentis.bwh.model.OrderPosition.pcReplaceField(OrderPosition.java)
> >>       at
> >> 
> org.apache.openjpa.kernel.StateManagerImpl.replaceField(StateM
> anagerImpl.java:3162)
> >>       at
> >> 
> org.apache.openjpa.kernel.StateManagerImpl.storeObjectField(St
> ateManagerImpl.java:2596)
> >>       at
> >> 
> org.apache.openjpa.kernel.StateManagerImpl.storeObject(StateMa
> nagerImpl.java:2586)
> >>       at
> >> 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.setMappedBy(JD
> BCStoreManager.java:505)
> >>       at
> >> 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeStat
> e(JDBCStoreManager.java:431)
> >>       at
> >> 
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDB
> CStoreManager.java:333)
> >>       at
> >> 
> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(De
> legatingStoreManager.java:112)
> >>       at
> >> 
> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreM
> anager.java:57)
> >>       at
> >> 
> org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1027)
> >>       at 
> org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:985)
> >>       ... 86 more
> >> ---
> >> regards
> >> Marc Logemann
> >> http://www.logemann.org
> >> http://www.logentis.de
> >> 
> >> 
> >> 
> >> 
> >> 
> 
> 

Reply via email to