Francisco A. Lozano
2009/9/3 Fabio Maulo <
fabiomaulo <at> gmail.com>:
> mmmm... me parece que voy a actualizar la implementación que viene con NH
> para verificar si pasó algo raro con 1.3. De todas formas le voy a preguntar
> a Mark si prefieren mantener ellos el codigo (así como está donado el
> EnhancedByteCode de uNhAddIns).
>
> El 3 de septiembre de 2009 00:43, Fabio Maulo <
fabiomaulo <at> gmail.com>
> escribió:
>>
>> Pero estas usando lo que viene con Spring1.3 ?
>> Tengo que hablar con Erich y Mark para saber que pasó.
>>
>> El 2 de septiembre de 2009 20:34, Francisco A. Lozano <
flozano <at> gmail.com>
>> escribió:
>>>
>>> Hola Fabio,
>>>
>>> Gracias por tan pronta respuesta... justo ahora iba a post'ear el
>>> error: es de spring y no de Nhibernate - de su proxyfactory,
>>> concretamente:
>>>
>>>
http://forum.springframework.net/showthread.php?t=5771
>>>
>>>
>>> Francisco A. Lozano
>>>
>>>
>>>
>>> 2009/9/3 Fabio Maulo <
fabiomaulo <at> gmail.com>:
>>> > Me parece que faltan las infos importantes....
>>> > DecoratorAopProxy_daa43fabda90407fb780755aca7b3054
>>> > eso viene de algun lado.
>>> > ProxyFactoryFactory usado ?
>>> > ObjectFactory usado ?
>>> > a ver las lineas al rededor de Configuration().Configure() y la conf de
>>> > NH...
>>> > La exception te dice que el proxy generado, para el lazy loading del
>>> > many-to-one, no se puede asignar a la propiedad y el proxy justo hereda
>>> > de
>>> > City así que se debería poder asignar a menos que no haya una custom
>>> > implementation de algo que tenga a que ver con el proxy.
>>> >
>>> > 2009/9/2 Francisco A. Lozano <
flozano <at> gmail.com>
>>> >>
>>> >> Hola,
>>> >>
>>> >> Estamos desarrollando una aplicación con NHibernate y Spring.NET.
>>> >>
>>> >> El código:
>>> >>
>>> >> public User GetByLogin(String login)
>>> >> {
>>> >> String hqlQuery = "From User u Where
>>> >> u.AuthenticationInformation.Login = :login";
>>> >>
>>> >> IQuery query = s.CreateQuery(hqlQuery);
>>> >> query.SetParameter("login", login);
>>> >> query.SetMaxResults(1);
>>> >>
>>> >> return query.UniqueResult<User>();
>>> >> }
>>> >>
>>> >>
>>> >> La excepción que recibimos es:
>>> >>
>>> >> Error de servidor en la aplicación '/Public'.
>>> >> No se puede convertir un objeto de tipo
>>> >> 'DecoratorAopProxy_daa43fabda90407fb780755aca7b3054' al tipo
>>> >> 'W.Domain.Geo.City'.
>>> >> Descripción: Excepción no controlada al ejecutar la solicitud Web
>>> >> actual. Revise el seguimiento de la pila para obtener más información
>>> >> acerca del error y dónde se originó en el código.
>>> >>
>>> >> Detalles de la excepción: System.InvalidCastException: No se puede
>>> >> convertir un objeto de tipo
>>> >> 'DecoratorAopProxy_daa43fabda90407fb780755aca7b3054' al tipo
>>> >> 'W.Domain.Geo.City'.
>>> >>
>>> >> Error de código fuente:
>>> >>
>>> >> Línea 35: query.SetMaxResults(1);
>>> >> Línea 36:
>>> >> Línea 37: return query.UniqueResult<User>();
>>> >> Línea 38: }
>>> >> Línea 39: }
>>> >>
>>> >>
>>> >> Archivo de origen:
>>> >>
>>> >> C:\Proyectos\Wimio\Wimio_Net\trunk\W\W.Persistence.NH\Users\NHUserDAO.cs
>>> >> Línea: 37
>>> >>
>>> >> Seguimiento de la pila:
>>> >>
>>> >> [InvalidCastException: No se puede convertir un objeto de tipo
>>> >> 'DecoratorAopProxy_daa43fabda90407fb780755aca7b3054' al tipo
>>> >> 'W.Domain.Geo.City'.]
>>> >> (Object , Object[] , SetterCallback ) +434
>>> >>
>>> >> NHibernate.Bytecode.Lightweight.AccessOptimizer.SetPropertyValues(Object
>>> >> target, Object[] values) +57
>>> >>
>>> >>
>>> >> NHibernate.Tuple.Component.PocoComponentTuplizer.SetPropertyValues(Object
>>> >> component, Object[] values) +85
>>> >> NHibernate.Type.ComponentType.SetPropertyValues(Object component,
>>> >> Object[] values, EntityMode entityMode) +57
>>> >> NHibernate.Type.ComponentType.ResolveIdentifier(Object value,
>>> >> ISessionImplementor session, Object owner) +290
>>> >> NHibernate.Engine.TwoPhaseLoad.InitializeEntity(Object entity,
>>> >> Boolean readOnly, ISessionImplementor session, PreLoadEvent
>>> >> preLoadEvent, PostLoadEvent postLoadEvent) +791
>>> >> NHibernate.Loader.Loader.InitializeEntitiesAndCollections(IList
>>> >> hydratedObjects, Object resultSetId, ISessionImplementor session,
>>> >> Boolean readOnly) +451
>>> >> NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
>>> >> QueryParameters queryParameters, Boolean returnProxies) +1427
>>> >>
>>> >>
>>> >> NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor
>>> >> session, QueryParameters queryParameters, Boolean returnProxies) +106
>>> >> NHibernate.Loader.Loader.DoList(ISessionImplementor session,
>>> >> QueryParameters queryParameters) +172
>>> >>
>>> >> [ADOException: could not execute query
>>> >> [ select user0_.`id` as id1_0_, user0_.`modified_at` as modified2_0_,
>>> >> user0_.`created_at` as created3_0_, user0_.`common_name` as
>>> >> common4_0_, user0_.`first_name` as first5_0_, user0_.`last_names` as
>>> >> last6_0_, user0_.`email_address` as email7_0_, user0_.`gender` as
>>> >> gender8_0_, user0_.`birth_date` as birth9_0_, user0_.`cancelled_at` as
>>> >> cancelled10_0_, user0_.`street` as street11_0_, user0_.`number` as
>>> >> number12_0_, user0_.`floor_and_others` as floor13_0_,
>>> >> user0_.`zip_code` as zip14_0_, user0_.`city` as city15_0_,
>>> >> user0_.`login` as login16_0_, user0_.`password` as password17_0_ from
>>> >> `user` user0_ where user0_.`login`=? ]
>>> >> Name:login - Value:Hiko
>>> >> [SQL: select user0_.`id` as id1_0_, user0_.`modified_at` as
>>> >> modified2_0_, user0_.`created_at` as created3_0_, user0_.`common_name`
>>> >> as common4_0_, user0_.`first_name` as first5_0_, user0_.`last_names`
>>> >> as last6_0_, user0_.`email_address` as email7_0_, user0_.`gender` as
>>> >> gender8_0_, user0_.`birth_date` as birth9_0_, user0_.`cancelled_at` as
>>> >> cancelled10_0_, user0_.`street` as street11_0_, user0_.`number` as
>>> >> number12_0_, user0_.`floor_and_others` as floor13_0_,
>>> >> user0_.`zip_code` as zip14_0_, user0_.`city` as city15_0_,
>>> >> user0_.`login` as login16_0_, user0_.`password` as password17_0_ from
>>> >> `user` user0_ where user0_.`login`=?]]
>>> >> NHibernate.Loader.Loader.DoList(ISessionImplementor session,
>>> >> QueryParameters queryParameters) +335
>>> >> NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor
>>> >> session, QueryParameters queryParameters) +46
>>> >> NHibernate.Loader.Loader.List(ISessionImplementor session,
>>> >> QueryParameters queryParameters, ISet`1 querySpaces, IType[]
>>> >> resultTypes) +155
>>> >> NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor
>>> >> session, QueryParameters queryParameters) +95
>>> >>
>>> >> NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor
>>> >> session, QueryParameters queryParameters) +625
>>> >> NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters
>>> >> queryParameters, ISessionImplementor session, IList results) +754
>>> >> NHibernate.Impl.SessionImpl.List(String query, QueryParameters
>>> >> queryParameters, IList results) +262
>>> >> NHibernate.Impl.SessionImpl.List(String query, QueryParameters
>>> >> parameters) +172
>>> >> NHibernate.Impl.QueryImpl.List() +149
>>> >> NHibernate.Impl.AbstractQueryImpl.UniqueResult() +33
>>> >> NHibernate.Impl.AbstractQueryImpl.UniqueResult() +44
>>> >> W.Persistence.NH.Users.NHUserDAO.GetByLogin(String login) in
>>> >>
>>> >>
>>> >> C:\Proyectos\Wimio\Wimio_Net\trunk\W\W.Persistence.NH\Users\NHUserDAO.cs:37
>>> >> W.Business.Users.UserService.GetByLogin(String login) in
>>> >>
>>> >> C:\Proyectos\Wimio\Wimio_Net\trunk\W\W.Business\Users\UserService.cs:88
>>> >>
>>> >>
>>> >> Las clases son "obvias" a partir del mapping... si no me lo pide nadie
>>> >> no las pego, que "User" es bastante grande. Las partes relevantes del
>>> >> mapping son:
>>> >>
>>> >> <class name="W.Domain.Users.User, W.Domain">
>>> >>
>>> >> <id name="Id">
>>> >> <generator class="hilo" />
>>> >> </id>
>>> >>
>>> >> <timestamp name="ModifiedAt" />
>>> >> <property name="CreatedAt" not-null="true" />
>>> >> <property name="CommonName" not-null="true" length="250"
>>> >> unique="true"/>
>>> >> <property name="FirstName" not-null="true" length="250" />
>>> >> <property name="LastNames" not-null="true" length="250" />
>>> >> <property name="EmailAddress" not-null="true" length="250"
>>> >> unique="true" />
>>> >> <property name="Gender" not-null="true" />
>>> >> <property name="BirthDate" not-null="true" />
>>> >> <property name="CancelledAt" not-null="false" />
>>> >>
>>> >> <component name="Home">
>>> >> <property name="Street" not-null="true" />
>>> >> <property name="Number" />
>>> >> <property name="FloorAndOthers" />
>>> >> <property name="ZipCode" />
>>> >> <many-to-one name="City" class="W.Domain.Geo.City,
>>> >> W.Domain" not-null="true" />
>>> >> </component>
>>> >>
>>> >> <component name="AuthenticationInformation">
>>> >> <property name="Login" not-null="true" length="250"
>>> >> unique="true" />
>>> >> <property name="Password" not-null="true" length="250" />
>>> >> </component>
>>> >>
>>> >> <one-to-one name="UsedJoinInvitation"
>>> >> class="W.Domain.Users.JoinInvitation, W.Domain" property-ref="UsedBy"
>>> >> />
>>> >>
>>> >> <bag name="Subjects" inverse="true" lazy="true"
>>> >> cascade="all-delete-orphan">
>>> >> <key column="user" />
>>> >> <one-to-many class="W.Domain.Core.Subject, W.Domain" />
>>> >> </bag>
>>> >>
>>> >> <bag name="Comments" inverse="true" lazy="true"
>>> >> cascade="all-delete-orphan">
>>> >> <key column="user" />
>>> >> <one-to-many class="W.Domain.Core.Comment, W.Domain" />
>>> >> </bag>
>>> >>
>>> >> <bag name="SentMessages" inverse="true" lazy="true"
>>> >> cascade="all-delete-orphan">
>>> >> <key column="sender" />
>>> >> <one-to-many class="W.Domain.Messaging.Message, W.Domain"/>
>>> >> </bag>
>>> >>
>>> >> <bag name="ReceivedMessages" inverse="true" lazy="true"
>>> >> cascade="all-delete-orphan">
>>> >> <key column="receiver" />
>>> >> <one-to-many class="W.Domain.Messaging.Message, W.Domain"/>
>>> >> </bag>
>>> >>
>>> >> <bag name="PlayLists" inverse="true" lazy="true"
>>> >> cascade="save-update">
>>> >> <key column="user" />
>>> >> <one-to-many class="W.Domain.Media.PlayList, W.Domain" />
>>> >> </bag>
>>> >>
>>> >> <bag name="MediaResources" inverse="true" lazy="true"
>>> >> cascade="save-update">
>>> >> <key column="user" />
>>> >> <one-to-many class="W.Domain.Media.MediaResource, W.Domain"
>>> >> />
>>> >> </bag>
>>> >>
>>> >> <bag name="CreatedPlaces" inverse="true" lazy="true"
>>> >> cascade="save-update">
>>> >> <key column="user" />
>>> >> <one-to-many class="W.Domain.Geo.Place, W.Domain"/>
>>> >> </bag>
>>> >>
>>> >> <map name="PrivateUserGroups" inverse="true" lazy="true"
>>> >> cascade="all-delete-orphan">
>>> >> <key column="user" />
>>> >> <index column="name" type="String" length="250" />
>>> >> <one-to-many class="W.Domain.Users.PrivateUserGroup,
>>> >> W.Domain"
>>> >> />
>>> >> </map>
>>> >>
>>> >> <map name="PublicUserGroups" inverse="true" lazy="true"
>>> >> cascade="save-update">
>>> >> <key column="user" />
>>> >> <index column="name" type="String" length="250" />
>>> >> <many-to-many class="W.Domain.Users.PublicUserGroup,
>>> >> W.Domain"
>>> >> />
>>> >> </map>
>>> >>
>>> >> <bag name="InverseContacts" inverse="true" lazy="true"
>>> >> cascade="all-delete-orphan">
>>> >> <key column="contact" />
>>> >> <one-to-many class="W.Domain.Users.Relationship, W.Domain"
>>> >> />
>>> >> </bag>
>>> >>
>>> >> <list name="StatusUpdates" inverse="true" lazy="true"
>>> >> cascade="all-delete-orphan">
>>> >> <key column="user" />
>>> >> <index column="position" type="int"/>
>>> >> <one-to-many class="W.Domain.Users.StatusUpdate, W.Domain"
>>> >> />
>>> >> </list>
>>> >>
>>> >> <map name="OtherProperties" table="user_property"
>>> >> cascade="all-delete-orphan">
>>> >> <key column="user" />
>>> >> <index column="property_name" type="String" length="250" />
>>> >> <element column="property_value" type="StringClob" />
>>> >> </map>
>>> >>
>>> >> </class>
>>> >>
>>> >> <class name="W.Domain.Geo.City, W.Domain" >
>>> >> <id name="Id">
>>> >> <generator class="hilo" />
>>> >> </id>
>>> >> <timestamp name="ModifiedAt" />
>>> >> <property name="CreatedAt" not-null="true" />
>>> >> <property name="Name" length="250" not-null="false" />
>>> >> <many-to-one name="StateProvince"
>>> >> class="W.Domain.Geo.StateProvince, W.Domain" not-null="true" />
>>> >>
>>> >> <bag name="Places" inverse="true" lazy="true"
>>> >> cascade="save-update">
>>> >> <key column="city" />
>>> >> <one-to-many class="W.Domain.Geo.Place, W.Domain"/>
>>> >> </bag>
>>> >>
>>> >> <bag name="Users" inverse="true" lazy="true" cascade="none">
>>> >> <key column="city" />
>>> >> <one-to-many class="W.Domain.Users.User, W.Domain"/>
>>> >> </bag>
>>> >>
>>> >> </class>
>>> >>
>>> >>
>>> >>
>>> >> Francisco A. Lozano
>>> >>
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Fabio Maulo
>>> >
>>> > >
>>> >
>>>
>>>
>>
>>
>>
>> --