openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Logemann ...@logemann.org>
Subject Re: org.apache.openjpa.util.LongId cannot be cast to MyDomainObject
Date Thu, 22 Dec 2011 16:55:18 GMT
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 <li@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(JDBCStoreManager.java:1041)
>>       at
>> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
>>       at
>> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2381)
>>       at
>> org.apache.openjpa.jdbc.meta.strats.RelationToManyInverseKeyFieldStrategy.loadElement(RelationToManyInverseKeyFieldStrategy.java:90)
>>       at
>> org.apache.openjpa.jdbc.meta.strats.RelationCollectionInverseKeyFieldStrategy.loadElement(RelationCollectionInverseKeyFieldStrategy.java:76)
>>       at
>> org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.processEagerParallelResult(StoreCollectionFieldStrategy.java:312)
>>       at
>> org.apache.openjpa.jdbc.meta.strats.StoreCollectionFieldStrategy.loadEagerParallel(StoreCollectionFieldStrategy.java:246)
>>       at
>> org.apache.openjpa.jdbc.meta.FieldMapping.loadEagerParallel(FieldMapping.java:916)
>>       at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1114)
>>       at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1067)
>>       at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:438)
>>       at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:333)
>>       at
>> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
>>       at
>> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.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(JDBCStoreManager.java:1041)
>>       at
>> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:280)
>>       at
>> org.apache.openjpa.jdbc.sql.SelectImpl$SelectResult.load(SelectImpl.java:2381)
>>       at
>> org.apache.openjpa.jdbc.sql.AbstractResult.load(AbstractResult.java:274)
>>       at
>> org.apache.openjpa.jdbc.kernel.InstanceResultObjectProvider.getResultObject(InstanceResultObjectProvider.java:59)
>>       at
>> org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.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(DelegatingQuery.java:542)
>>       at
>> org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:315)
>>       at
>> org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:331)
>>       at
>> de.netstorsys.dao.repositories.ContainerShipmentRepositoryImpl.findAllCustom(ContainerShipmentRepositoryImpl.java:39)
>>       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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:311)
>>       at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
>>       at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
>>       at
>> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
>>       at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>>       at
>> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
>>       at $Proxy903.findAllCustom(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.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:368)
>>       at
>> org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:338)
>>       at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>>       at
>> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
>>       at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>>       at
>> org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
>>       at
>> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
>>       at
>> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.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(NativeMethodAccessorImpl.java:39)
>>       at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>       at java.lang.reflect.Method.invoke(Method.java:597)
>>       at
>> org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
>>       at
>> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
>>       at
>> org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
>>       at
>> org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
>>       at
>> org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
>>       at
>> org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
>>       at
>> org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.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.internalDoFilter(ApplicationFilterChain.java:290)
>>       at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>>       at
>> org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
>>       at
>> org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
>>       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:233)
>>       at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>>       at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>       at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>       at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>>       at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
>>       at
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
>>       at
>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.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(StateManagerImpl.java:3162)
>>       at
>> org.apache.openjpa.kernel.StateManagerImpl.storeObjectField(StateManagerImpl.java:2596)
>>       at
>> org.apache.openjpa.kernel.StateManagerImpl.storeObject(StateManagerImpl.java:2586)
>>       at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.setMappedBy(JDBCStoreManager.java:505)
>>       at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:431)
>>       at
>> org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:333)
>>       at
>> org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112)
>>       at
>> org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.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
>> 
>> 
>> 
>> 
>> 


Mime
View raw message