|
Re: [Teneo] Class cast exception [message #424858 is a reply to message #424856] |
Fri, 07 November 2008 10:28 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
It seems to be related to this:
http://www.hibernate.org/hib_docs/reference/en/html/performa nce.html#performance-fetching-proxies
Normally this should not be a problem.
What is the model of LocationType? It seems to go wrong when a LocationType is set in the Location.
gr. Martin
David Wynter wrote:
> Hi,
>
> From this code (we changed it to an Object in the for loop to get a
> better trace)
>
>
> // open transaction
> Session session = HibernateUtil.getCurrentSession();
> Transaction tx = session.beginTransaction();
>
> try
> {
> Query query = session.createQuery("from IssuerClass where id = ?");
> query.setInteger(0, issuerId);
>
> Object object = query.uniqueResult();
> if (object instanceof IssuerClass) {
>
> EList<Location> locations = ((IssuerClass)object).getLocation();
> Location location = null ;
> for (Object o : locations)
> location = (Location) o ;
> ....
>
> we get
>
> Caused by: java.lang.ClassCastException:
> org.eclipse.emf.teneo.hibernate.mapping.internal.TeneoIntern alEObject_$$_javassist_16
> cannot be cast to com.stpenable.gensec.LocationType
> at com.stpenable.gensec.impl.LocationImpl.eSet(LocationImpl.jav a:1085)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjec tImpl.java:1071)
>
> at
> org.eclipse.emf.teneo.hibernate.mapping.property.EReferenceP ropertyHandler.set(EReferencePropertyHandler.java:150)
>
> at
> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:360)
>
> setLocationType((LocationType)newValue);
> com.stpenable.gensec.impl.LocationTypeImpl@19e244f (full: domicile, id:
> <unset>, scheme: mddl3b, short: domicile)
> newValue TeneoInternalEObject_$$_javassist_16 (id=191)
> handler JavassistLazyInitializer (id=195)
>
> What have we done wrong?
>
> Here is the xsd excerpt
>
> <xsd:complexType name="IssuerClass">
> <xsd:sequence>
> <xsd:element ecore:opposite="issuerClass" minOccurs="0"
> maxOccurs="unbounded" ref="gensec:location" />
> ..... etc.
>
> Thx.
>
> David
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
|
|
Re: [Teneo] Class cast exception [message #424872 is a reply to message #424871] |
Fri, 07 November 2008 15:27 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
Yes it is possible that it does not apply to your case (I did not know the whole model when reacting
to your post).
No constructor is the same as a public constructor without parameters.
I tested this model and the LocationType with me is of this type:
locationType LocationType$$EnhancerByCGLIB$$e0f520b9 (id=49)
this is correct, so it is cglib enhanced but still has the main type (LocationType).
So maybe you generated your code in a different way than I did?
Or can you send me the whole model with genmodel and testcase?
gr. Martin
David Wynter wrote:
> Hi,
>
> I cannot see the correlation between the performance fetching proxies
> you show the link to and this problem, because we have no subclass here?
> It is a straight IssuerClass 1..n Location 0..1 LocationType set of
> relationships.
>
> Based on this statement from the page you linked to "Note that the
> proxied class must implement a default constructor with at least package
> visibility. We recommend this constructor for all persistent classes! "
> is there a reason no default constructor with the required visibility is
> generated by Teneo?
>
> Thx.
>
> David
>
> Martin Taal wrote:
>> Hi David,
>> It seems to be related to this:
>> http://www.hibernate.org/hib_docs/reference/en/html/performa nce.html#performance-fetching-proxies
>>
>>
>> Normally this should not be a problem.
>>
>> What is the model of LocationType? It seems to go wrong when a
>> LocationType is set in the Location.
>>
>> gr. Martin
>>
>> David Wynter wrote:
>>> Hi,
>>>
>>> From this code (we changed it to an Object in the for loop to get a
>>> better trace)
>>>
>>>
>>> // open transaction
>>> Session session = HibernateUtil.getCurrentSession();
>>> Transaction tx = session.beginTransaction();
>>> try
>>> {
>>> Query query = session.createQuery("from IssuerClass where id = ?");
>>> query.setInteger(0, issuerId);
>>> Object object = query.uniqueResult();
>>> if (object instanceof IssuerClass) {
>>>
>>> EList<Location> locations = ((IssuerClass)object).getLocation();
>>> Location location = null ;
>>> for (Object o : locations)
>>> location = (Location) o ;
>>> ....
>>>
>>> we get
>>>
>>> Caused by: java.lang.ClassCastException:
>>> org.eclipse.emf.teneo.hibernate.mapping.internal.TeneoIntern alEObject_$$_javassist_16
>>> cannot be cast to com.stpenable.gensec.LocationType
>>> at com.stpenable.gensec.impl.LocationImpl.eSet(LocationImpl.jav a:1085)
>>> at
>>> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjec tImpl.java:1071)
>>>
>>> at
>>> org.eclipse.emf.teneo.hibernate.mapping.property.EReferenceP ropertyHandler.set(EReferencePropertyHandler.java:150)
>>>
>>> at
>>> org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropert yValues(AbstractEntityTuplizer.java:360)
>>>
>>> setLocationType((LocationType)newValue);
>>> com.stpenable.gensec.impl.LocationTypeImpl@19e244f (full: domicile,
>>> id: <unset>, scheme: mddl3b, short: domicile)
>>> newValue TeneoInternalEObject_$$_javassist_16 (id=191)
>>> handler JavassistLazyInitializer (id=195)
>>>
>>> What have we done wrong?
>>>
>>> Here is the xsd excerpt
>>>
>>> <xsd:complexType name="IssuerClass">
>>> <xsd:sequence>
>>> <xsd:element ecore:opposite="issuerClass" minOccurs="0"
>>> maxOccurs="unbounded" ref="gensec:location" />
>>> ..... etc.
>>>
>>> Thx.
>>>
>>> David
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Powered by
FUDForum. Page generated in 0.03686 seconds