These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Lazy load property mapped with custom type
PostPosted: Thu Jul 26, 2007 11:23 am 
Newbie

Joined: Wed May 23, 2007 2:36 pm
Posts: 2
Hi there,

I'm currently facing a problem I really can't help myself... "Reading the internet" hasn't really helped though it might be more than possible that someone else has faced that problem before. But I'm too stuck i guess... =)

I'm having a class Node which looks like this in the mapping file

Code:
<hibernate-mapping auto-import="false" xmlns="urn:nhibernate-mapping-2.2">
  <class name="bsp1.Node, BinaryTreeAdvanced" table="`NODE`">
    <id name="m_id" column="ID" type="integer" access="field">
      <generator class="identity"/>
    </id>
    <property name="m_timestamp" column="TS" [b]type="MyTimestampType, pmMDA.NET.Common"[/b] not-null="false" access="field"/>
    <property name="m_value" column="VALUE" access="field" type="Int32" not-null="false"/>
    <many-to-one name="m_right" column="RIGHT_FK" class="bsp1.Node, BinaryTreeAdvanced" access="field" not-null="false"/>
    <many-to-one name="m_left" column="LEFT_FK" class="bsp1.Node, BinaryTreeAdvanced" access="field" not-null="false"/>
  </class>
</hibernate-mapping>


Now when i lazily load an object of type bsp1.Node a proxy is generated (as it should be - that's good so far). But somehow the m_timestamp property isn't included in this generated proxy.

Am i totally wrong in my assumption that DynamicProxy should generate the m_timestamp property as a property and load its value like it does for the ID (m_id) and the m_value property?

Is there a special thing I need to consider when implementing my special MyTimestampType? Does the class have to implement any special interface or something like that?

Basically my class looks like that:

Code:
public class MyTimestampType : ValueTypeType
  {
    public MyTimestampType() : base(new SqlDateTimeType().SqlType)
    {       
    }

    public override object Get(IDataReader rs, int index)
    {
      DateTime t = Convert.ToDateTime(rs[index]);
      return t;
    }

    <some code snipped here>
}


Thanks for any of your help.
Ruth

Hibernate version:1.2.0.4
Mapping documents: see above
Name and version of the database you are using: MSSSQL Server 2005


Top
 Profile  
 
 Post subject: Re: Lazy load property mapped with custom type
PostPosted: Fri Jul 27, 2007 4:07 am 
Newbie

Joined: Wed May 23, 2007 2:36 pm
Posts: 2
Well, this morning I've found the solution for my problem. It is really simple, so in fact it really was a blockhead...

Basically DynamicProxy can only proxy properties and methods which are declared as virtual.

Snippet from http://www.castleproject.org/dynamicproxy:
Quote:
For concrete classes, only virtual methods can be intercepted as the approach is to create a sub class of your class, which overrides all virtual methods (public and protected as well) and dispatches the invocations to the interceptor.


Sorry for bothering you with a silly question like this...

Have a nice weekend
Ruth


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.