Re: org.apache.openjpa.util.LongId cannot be cast to MyDomainObject

2011-12-27 Thread Marc Logemann
Then i dont get the "referencedColumnName" Feature, because the db field of the 
@ID fields doesnt need to be declared, this JPA does already know. 
I will migrate it nevertheless and leave out the "referencedColumnName" 
completely.

---
regards
Marc Logemann
http://www.logemann.org
http://www.logentis.de




Am 23.12.2011 um 09:39 schrieb Boblitz John:

> 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 
>>  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;
>>>> 
>>&g

AW: org.apache.openjpa.util.LongId cannot be cast to MyDomainObject

2011-12-23 Thread Boblitz John
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 
>  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 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 TransferFieldMana

Re: org.apache.openjpa.util.LongId cannot be cast to MyDomainObject

2011-12-22 Thread Marc Logemann
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  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 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.
>> 
>> 
>> 
>> 
>> 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.

Re: org.apache.openjpa.util.LongId cannot be cast to MyDomainObject

2011-12-22 Thread 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  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 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.
>
>
>
> 
> 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.

org.apache.openjpa.util.LongId cannot be cast to MyDomainObject

2011-12-22 Thread Marc Logemann
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 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.



 
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.(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.NativeMethodAccessorIm