Thanks for the advice. Its is nice to know that I am not alone.

I have been using the debugger to examine the objects hibernate uses.

The object I am marshaling has a field called 'state' which is defined
to be a EntityState object. So my Castor mapping is

<field name="State" type="inform.orm.entity.EntityState"
container="true"/>

and 
<class name="inform.orm.entity.EntityState" auto-complete="false">
        <field name="description">
                <bind-xml name="state" node="attribute" />              
        </field>
</class>

However when I examine the class with the debugger, I find that the
actual object in field 'state' is an instance of
EntityState$$EnhancerByCGLIB$$c147c74c  It looks as if hibernate is
doing some bit code enhancement (even though I have configured it not
to)

I presume that Castor, as it doesn't find the expected object, starts
inspecting all the fields on the object.

If this is correct, I suspect that a better approach would have been to
only inspect the fields that the expected object had listed. E.g in my
case it should have simply inspected the description field.

Richard


> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]
> Sent: Friday, 4 March 2005 5:45 a.m.
> To: [email protected]
> Subject: Re: [castor-user] [XML] Castor error with hibernator V3
> 
> 
> Richard Schmidt wrote:
> > Hi
> >
> > I have an application that uses Hibernate to load objects from the
> > database and Castor to map the objects to XML.
> >
> > I upgraded to Hibernate Version 3. Since then the Castor XML side
has
> > not worked correctly.
> >
> > I suspect that it has something to do with hibernate using proxies
when
> > loading a collection as castor starts 'walking' the proxy object.
> >
> > All the classes in my Castor mapping files have been marked as
> > 'auto-complete = "false"'.
> 
> Two questions come to mind here. The first is what does your class
> mapping look like? The auto-complete="false" will prevent Castor from
> introspection the remainder of the class, but if you specify some
fields
> in your mapping castor will still use those fields unless you mark
them
> as transient.
> 
> Also how are you configuring and calling the marshaller? Make sure you
> are not using one of the static Marshaller#marshal methods, if you use
a
> static method, Castor won't have access to any mapping file that you
> have set on the Marshaller.
> 
> Also, is Hibernate actually modifying the class? If so, when you load
> the mapping file, make sure use whatever special class loader that
> Hibernate uses. If you don't use the correct class loader Castor might
> not be finding the proper mapping (since a class loaded by one class
> loader is not equal to a class loaded by a different mapping loader).
> 
> 
> --Keith
> 
> >
> >
> > Eventually the application crashes with an AbstractMethodError
thrown by
> > the SQLServerConnection.
> >
> >
> > The XML output produced by Castor is show below - I have marked
where
> > Castor starts inspecting the Hibernate proxy object.
> >
> > Thanks
> > Richard
> >
> >
> >
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <entity clientno="ASH141"
> >     state="Active                                  " isClient="true"
> >     type="INDIVIDUAL                              " isPerson="true">
> >     <reportingname>Dr Lionel J D Ashtona &amp; Mrs Jane Ashton
> > </reportingname>
> >
> > **********************************************ERROR FROM HERE
> > ON*************************************
> >     <hibernate-lazy-initializer uninitialized="false"
> > xsi:type="java:org.hibernate.proxy.CGLIBLazyInitializer">
> >         <implementation state="Active
"
> >             isClient="true" xsi:type="entity-state"/>
> >         <identifier xsi:type="java:java.lang.String">A</identifier>
> >         <entity-name>inform.orm.entity.EntityState</entity-name>
> >         <session dirty="false"
flush-before-completion-enabled="false"
> >             connected="true" open="true" dont-flush-from-find="0"
> >             flush-mode-never="false" timestamp="4545407439429632"
> > xsi:type="java:org.hibernate.impl.SessionImpl">
> >             <batcher
> > xsi:type="java:org.hibernate.jdbc.NonBatchingBatcher"/>
> >             <factory
> > xsi:type="java:org.hibernate.impl.SessionFactoryImpl">
> >                 <statistics successful-transaction-count="0"
> >                     collection-load-count="0" connect-count="0"
> >                     query-cache-put-count="0"
entity-insert-count="0"
> >                     collection-update-count="0"
> >                     query-execution-max-time="0"
> >                     collection-remove-count="0"
> >                     query-cache-hit-count="0"
entity-update-count="0"
> >                     second-level-cache-put-count="0" flush-count="0"
> >                     collection-fetch-count="0"
session-open-count="0"
> >                     start-time="1109718610671"
> >                     second-level-cache-miss-count="0"
> >                     entity-fetch-count="0"
collection-recreate-count="0"
> >                     second-level-cache-hit-count="0"
> >                     entity-delete-count="0" session-close-count="0"
> >                     query-execution-count="0" transaction-count="0"
> >                     statistics-enabled="false"
> >                     query-cache-miss-count="0" entity-load-count="0"
> > xsi:type="java:org.hibernate.stat.StatisticsImpl">
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$EntityColumn</entit
> > y-names>
> >
> > <entity-names>inform.orm.address.Address</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$DateColumn</entity-
> > names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$TableColumn</entity
> > -names>
> >
> >
<entity-names>inform.orm.clientrelationship.Relationship</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$URLColumn</entity-n
> > ames>
> >
> > <entity-names>inform.orm.preferences.PrefsKey</entity-names>
> >
<entity-names>inform.orm.user.CloUser</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$OptionsColumn</enti
> > ty-names>
> >
> > <entity-names>inform.orm.feeearner.FeeEarner</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$MatterMultivalueCol
> > umn</entity-names>
> >                     <entity-names>EntityMT</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$AddressColumn</enti
> > ty-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$MatterColumn</entit
> > y-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$FeeEarnerColumn</en
> > tity-names>
> >
> > <entity-names>inform.orm.externaltables.ExtnTable</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$ClientMultivalueCol
> > umn</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$DecimalColumn</enti
> > ty-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$NoteColumn</entity-
> > names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$StringColumn</entit
> > y-names>
> >
> > <entity-names>inform.orm.entity.Entity</entity-names>
> >
> > <entity-names>inform.orm.matter.MatterCustomTables</entity-names>
> >
> > <entity-names>inform.orm.matter.Matter</entity-names>
> >
> > <entity-names>inform.orm.entity.EntityAddress</entity-names>
> >
> > <entity-names>inform.orm.entity.EntityType</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$LableColumn</entity
> > -names>
> >
> > <entity-names>inform.orm.externaltables.CustomColumn</entity-names>
> >
> > <entity-names>inform.orm.preferences.PrefsNode</entity-names>
> >                     <entity-names>wg01</entity-names>
> >
> > <entity-names>inform.orm.entity.EntityState</entity-names>
> >                     <entity-names>wg02</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$IntegerColumn</enti
> > ty-names>
> >                     <entity-names>country</entity-names>
> >
> > <entity-names>inform.orm.entity.ClientExtCustomTable</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$BooleanColumn</enti
> > ty-names>
> >
> >
<entity-names>inform.orm.clientrelationship.RelationshipType</entity-nam
> > es>
> >
> >
<collection-role-names>inform.orm.preferences.PrefsNode.Children</collec
> > tion-role-names>
> >
> >
<collection-role-names>inform.orm.preferences.PrefsNode.Keys</collection
> > -role-names>
> >
> >
<collection-role-names>inform.orm.externaltables.ExtnTable.columns</coll
> > ection-role-names>
> >
> >
<collection-role-names>inform.orm.entity.ClientExtCustomTable.inform.orm
> > .entity.ClientExtCustomTable.fields.multi</collection-role-names>
> >
> >
<collection-role-names>inform.orm.feeearner.FeeEarner.liasionMatters</co
> > llection-role-names>
> >
> >
<collection-role-names>inform.orm.entity.Entity.entityAddress</collectio
> > n-role-names>
> >
> >
<collection-role-names>inform.orm.feeearner.FeeEarner.actingMatters</col
> > lection-role-names>
> >
> >
<collection-role-names>inform.orm.user.CloUser.Prefsnodes</collection-ro
> > le-names>
> >
> >
<collection-role-names>inform.orm.entity.Entity.matters</collection-role
> > -names>
> >
> >
<collection-role-names>inform.orm.entity.Entity.entityRelationships</col
> > lection-role-names>
> >
> >
<collection-role-names>inform.orm.feeearner.FeeEarner.clientsResponsible
> > For</collection-role-names>
> >                 </statistics>
> >                 <transaction-factory
> > xsi:type="java:org.hibernate.transaction.JDBCTransactionFactory"/>
> >                 <statistics-implementor
successful-transaction-count="0"
> >                     collection-load-count="0" connect-count="0"
> >                     query-cache-put-count="0"
entity-insert-count="0"
> >                     collection-update-count="0"
> >                     query-execution-max-time="0"
> >                     collection-remove-count="0"
> >                     query-cache-hit-count="0"
entity-update-count="0"
> >                     second-level-cache-put-count="0" flush-count="0"
> >                     collection-fetch-count="0"
session-open-count="0"
> >                     start-time="1109718610671"
> >                     second-level-cache-miss-count="0"
> >                     entity-fetch-count="0"
collection-recreate-count="0"
> >                     second-level-cache-hit-count="0"
> >                     entity-delete-count="0" session-close-count="0"
> >                     query-execution-count="0" transaction-count="0"
> >                     statistics-enabled="false"
> >                     query-cache-miss-count="0" entity-load-count="0"
> > xsi:type="java:org.hibernate.stat.StatisticsImpl">
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$EntityColumn</entit
> > y-names>
> >
> > <entity-names>inform.orm.address.Address</entity-names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$DateColumn</entity-
> > names>
> >
> >
<entity-names>inform.orm.externaltables.CustomColumn$TableColumn</entity
> > -n
> >
> >
######################################################################
> > Attention:
> > This e-mail message is privileged and confidential. If you are not
the
> > intended recipient please delete the message and notify the sender.
> > Any views or opinions presented are solely those of the author.
> >
> >
######################################################################
> >
> >
> >
> >
------------------------------------------------------------------------
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-user
> 
> 
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user
######################################################################
Attention: 
This e-mail message is privileged and confidential. If you are not the 
intended recipient please delete the message and notify the sender. 
Any views or opinions presented are solely those of the author.

######################################################################

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to